PP6a.gpio Interrupts
PP6a.gpio Interrupts
PP6a.gpio Interrupts
Interrupt Summary
Determine the name of the interrupt
handler (from vector table) & interrupt
index (from derivative.h)
Create interrupt handler function
Create interrupt setup function
11/09/2015
Interrupt handler
Use whatever name is given in the
vector table.
Should clear the interrupt flag (if it
exists) check hardware details.
Carry out whatever function is needed.
May need to do some setup for the
next interrupt e.g. schedule timer.
11/09/2015
Interrupt Setup
Initialise hardware
Do whatever setup is required e.g. set tick
rate etc.
Enable interrupt signal (unmask it) in
hardware
11/09/2015
11/09/2015
IRQ PTC.0
Interrupt Flag
w1c = write-1-to-clear
Controls Interrupt
function
11/09/2015
0000
0001
0010
0011
0100
1000
1001
1010
1011
1100
Write PORT_PCR_IRQC(10) to
enable falling edge
interrupts on port pin
Controls Interrupt
function
11/09/2015
...
1010 Interrupt on falling edge.
...
/*!
weak name used in vector table
* PORTC Interrupt Handler
* Toggles a pin
*/
Writing PORT_PCR_ISF_MASK
void PORTC_IRQHandler(void) {
// Toggle the LED
PORTC_PCR will clear the
GPIOA->PTOR = LED_MASK;
// Clear the interrupt flag
PORTC->PCR[0] = PORT_PCR_MUX(1)|PORT_PCR_IRQC(10)|PORT_PCR_ISF_MASK|
PORT_PCR_PFE_MASK|PORT_PCR_PE_MASK|PORT_PCR_PS_MASK;
}
to
flag
Interrupt Flag
Set by hardware
Cleared by software (w1c = write-1-to-clear)
11/09/2015
void PORTC_IRQHandler(void)
WEAK_DEFAULT_HANDLER;
PORTC_IRQHandler()
10