> Well, I've made some progress. I made a bit of a mistake in my > interrupt initialization. That was bad. I've fixed that and it seems > to be working closer to what I expected it to. Congratulations! > > This brings up a few questions that I've been thinking about in > regards to interrupt service routines. These are all based on code > I've seen other people write. > > 1. Is it necessary to do go back and poll all the possible interrupt > flags after servicing one of them? I always figured if I had an > overlapping interrupt that I'd jump right back into the ISR so there > wasn't much point in rechecking everything. > I like to do a while loop on the interrupt flag. This reduces the amount of time lost due to interrupt latency. I don't go back and check them all again once I've gone through my list of devices I'm polling, I just poll each one with a while loop, then, when it has nothing more, I go on to the next or exit the ISR if it's the last device. Similarly with vectored interrupts in the PIC24 or PIC32, I use a while loop for the single IF that vector represents. > 2. Do most people check the interrupt enable before checking the flag > to determine the source of the interrupt? I've only really seen one > person do this consistently, and it was because they were changing the > status (enabling and disabling) a few of the interrupts over the > course of the program. In my problem above, had I been doing this I > would have seen that the cause of my entering the ISR was not what I > had thought it was. > It depends on the interrupt. The only IE I turn on and off is typically a uart transmit interrupt. I turn it on when I put something in a fifo and turn it off when I transmit the last thing in the FIFO. In the ISR, I can either check to see if IE is on, then skip the transmit routine if it is not, or check how much is in the FIFO. Checking how much is in the FIFO is generally what I do. I'll loop while there's something in the FIFO and the UART has room. When I exit the loop, I turn off IE if the FIFO is empty and leave it on if the FIFO is not. For an interrupt that is on all the time (like a UART receive), I don't see a need to check IE. If there's something need to deal with it. Harold -- FCC Rules Updated Daily at http://www.hallikainen.com - Advertising opportunities available! -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist