Page 253 - Mechatronics with Experiments
P. 253
MICROCONTROLLERS 239
void at_high_interrupt_vector(void)
{
_asm
goto High_ISR
_endasm
}
#pragma code /∗ Restore the default program memory allocation. ∗/
#pragma interrupt High_ISR
void High_ISR(void)
{
....
....
....
}
/∗ ...... Low Priority Interrupt Service Routine (ISR) Setup ∗/
#pragma code LOW_INTERRUPT_VECTOR = 0x18
/∗ Place the following code starting at
address 0x18, which is the location for
low priority interrupt vector ∗/
void at_low_interrupt_vector(void)
{
_asm
goto Low_ISR
_endasm
}
#pragma code
/∗ Restore the default program memory allocation. ∗/
#pragma interruptlow Low_ISR
void Low_ISR(void)
{
....
....
....
}
#pragma code /∗ Restore the default program memory allocation. ∗/
Example: Interrupt Handling with PIC 18F452 on PICDEM 2 Plus
Demo Board This example requires:
1. hardware: the PICDEM 2 Plus Demo board with PIC 18F452 microcontroller chip
and MPLAB ICD 3 (in-circuit debugger) hardware,
2. software: MPLAB IDE v6.xx and MPLAB C18 development tools.
The INT0 pin is connected to a switch which is an external interrupt. It is a high
priority interrupt. Therefore, when this interrupt occurs, the program will branch to the
interrupt vector table location 0x0008h and get the address of the interrupt service routine
to branch to. By default, this address contains the address of the interrupt service routine
called high_ISR. Hence, when INT0 occurs, the program will branch to the high_ISR