There seems to be a lot of questions as well as misinformation about PIC18F interrupts and the robot code/devices. I thought a separate thread to ask more general questions would be worthwhile.
The purpose of this thread is share technical information at a detail level that most team members and even programmers won't care about. That's because building a solid device interrupt service routine only needs to be crafted once and then used multiple times. So if you're one of those crazies that want to understand how to craft interrupt service routines then welcome and have at it!
The are a couple documents that serve well for information:
DS31008A 33023a.pdf PICmicro™Mid-Range MCU Family Reference Manual
DS39646B 39646b.pdf PIC18F8722 Family Data Sheet
DS00097D MPLAB® C18 C COMPILER USER’S GUIDE
These documents, and more, are available from the Microchip website. For example, there are chip errata sheets that explain specific flaws that appear in specific chip models and how to get around them. There may be newer versions of the above, but these are the ones I currently have downloaded and use for references.
To answer a question, PLEASE DONT GUESS! Look it up and post the answer and reference if there is one.
For example, someone asked about interrupt latency in another thread. The chip latency is defined in DS31008A above as:
Quote:
Section 8.3
:
Interrupt latency is defined as the time from the interrupt event (the interrupt flag bit gets set) to the time that the instruction at <the interrupt vector address> starts execution (when that interrupt is enabled).
DS31008A-page 8-10
|
The interrupt latency is 3-4 instruction cycles in all cases, or 0.3-0.4 usec. The lower 0x7FF address range is protected by the configuration bits of the chip within the IFI controller as that is where the boot loader and other code resides. So there is a jump from the standard high/low priority vectors up to relocated vectors at 0x808 and 0x818. The standard IFI low priority interrupt handler starts with
Code:
#pragma code InterruptVectorReset = LOW_INT_VECTOR
void InterruptVectorLow (void)
{
_asm
goto InterruptHandlerLow /*jump to interrupt routine*/
_endasm
}
This IFI code just jumps to the real start of the service routine. So taking into account the chip latency of 3-4 instruction cycles and two GOTO instructions which are 2 cycles each, the user supplied interrupt handler will take 0.7-0.8usec before it starts execution.
If curious, you an see some of this information in the attached image in MPLAB's View->Program Memory window.