Chapter 7: Microcontroller Interrupts and Timers
MSK = (1<<PCIE0)|(1<<PCIE1);
ined by the address ‘vector’
f the data book. We use the following code to access
SIGNAL(SIG_PIN_CHANGE1)
ctory in signal.h, which defines
piler. We’ll get to
specifically for a particular microcontroller and a
articular C compiler and it is not portable like most of C. The original Butterfly
#pragma vector = PCINT0_vect
__interrupt void PCINT0_interrupt(void)
mething
}
EIFR = (1<<PCIF0)|(1<<PCIF1);
EI
The program will jump to the interrupt routine when the interrupt is triggered, but
where is the interrupt routine? The location is determ
listed in Table 22, page 47 o
the PCI1 interrupt:
{
// Do something
}
SIGNAL is defined in the WinAVR include dire
some macros to handle interrupt functions using the gcc com
macros later.
Interrupt handling is defined
p
code was built using the IAR C compiler and uses this format for interrupts:
{
// Do so
We’ll get to pragmas later. IAR handles interrupts one-way and WinAVR does it
another.
Let’s review:
- We setup a register, PCMSK1, to indicate which port B pins can cause
interrupts. - We setup the External Interrupt Mask Register, EIMSK, and External
Interrupt Flag Register, to enable the PCI1 interrupt. - We provided the SIGNAL(SIG_PIN_CHANGE1) code to be called when
the interrupt occurs.