angad wrote:Your example looks good but I want the External ISR functionality itself to perform a few things before it exits out.
The example was intended as a simple demonstration of the occurrence of an external event. It isn't particularly useful for anything else but it can be used as a starting point and can be incrementally refined to arrive at your intended destination.
angad wrote:The thing is 'getqueue' function waits until the specific number of bytes is available. While it waits for the data to be available, if emergency S/W is activated, I want the ISR to send a special string to corresponding controllers.
It is important to understand that you should not perform any activity in an ISR that has an arbitrarily long execution time, e.g. waiting for a given number of characters to appear in a queue. To reiterate, an ISR should be as short as possible. The ideal ISR just sets a flag and returns. Sometimes, you must resort to doing additional work but the objective should be to do absolutely as little as possible in the ISR.
In my earlier reply, I attempted to explain why you shouldn't attempt serial I/O (of any type, including Debug.Print) in an ISR. Apparently, I failed to make it clear. The crux of the problem is that for the duration of the execution of an ISR, interrupts are disabled. (As a side note, it is possible to re-enable interrupts but this is generally a "bad idea" for reasons that I won't go into at this time.) Consider, then, what can happen when you try to put data in the output queue for a serial port from within the ISR. If the queue is currently full, the PutQueue() call will sit in a loop waiting for space to become available. However, since interrupts are disabled, the serial I/O handler will never run and therefore space will never be available in the output queue. Your application will be hung, waiting forever.
angad wrote:I tried my ISR with a debug in main and a different debug message in ISR.
As explained above, you
should not output debug messages from within an ISR.
angad wrote:For some reason, when I provided the external interrupt trigger, the complete application hanged.
Just as I described above that it might.
angad wrote:I could give you my code, but I dont want to confuse you with the other functionalities in my code.
You could, of course, produce a stripped down example of what you want to do. Once we see that we might have some suggestions for alternate implementation strategies.