Interrupts are something like, if you touch a hot stove, the sensor in your hand detects "something's wrong". That signal goes to a specific location in the brain and causes a muscle action to happen. You don't think about it - it just happens. No matter what you WERE doing before, your hand is going to yank back NOW! You'll then go back to what you were doing before you touched the hot stove.
More technically speaking, when a hardware interrupt is enabled, and one occurs, the hardware gates in the PIC direct the program pointer to a specific location in memory where the interrupt subroutine's address is stored. The program pointer gets the address of the interrupt service routine and then goes there to handle the interrupt. Once the interrupt handling routine (that you wrote) is done, then the program goes back to where it was based on what it was doing at the time of the interrupt.
Example: You were blinking an LED on Port A.0. All is well. In your program you configured the Port B.0 pin for interrupt on low-to-high transition and enable the Port B.0 interrupt. Then you pushed a button that connects 5v to Port B.0. The blink portion of the program is stopped, and the chip's internal program pointer goes to the interrupt location in memory and looks for the address of your interrupt handler, and goes there. Once it gets to the end of that routine, then action resumes in the main program (blinking the A.0 LED) where it left off before the interrupt occured.
You can do this via two methods - PBP or DT INTS. It really depends on how fast you want to handle the interrupt and how much you want to "do it the right way", I guess. In other languages and chips, I've always used hardware interrupts and prefer to handle them as fast as possible and with as little impact on the running program as possible. Often times the interrupt is something that's just plain boring or bothersome like an input character from a USART, a counter rolling over, a timer rollover, odometer tic, etc. Nothing you really want to redirect the main program over, but something that still needs to be addressed and then move on back to what you were doing before. Interrupts using DT INTS is the fastest way, and probably (technically) the right way to handle PIC interrupts while using PBP as your language. I strongly suggest learning more about interrupts at the hardware level (RTFM) before you attempt DT INTS. While Dave's documentation is good, it assumes you know what/how/why interrupt in the first place. Not a good place for a newbie to go off exploring without some guidance.
Hope this helped,
rswain
Bookmarks