Does anyone have experience setting up an io pin has the source for an external interrupt,
or know of a application note or sample project that has details about how this is done?
I'm new to ARM and the API's which were generated with atmel start are hard for me to follow
as I'm used to operating on registers directly, as opposed to accessing through API.
From application note AT12784 the following steps are copied for reference:
Configuring an interrupt source requires six steps:
1. Implement interrupt handler if necessary:
The first step is to re-implement the interrupt handler with the same name as the default interrupt
handler in the vector table as just mentioned if necessary, so that when the corresponding interrupt
occurs, the reimplemented interrupt handler will be executed instead of the default interrupt
2. Disable the interrupt in case it was enabled
An interrupt triggering before its initialization completion may result in unpredictable behavior of the
system. To disable the interrupt, the Interrupt Clear-Enable Register (ICER) of the NVIC must be
written with the interrupt source ID to mask it. The following interface can be used directly:
static inline void NVIC_DisableIRQ(IRQn_Type IRQn);
3. Clear any pending interrupt, if any
Setting the Interrupt Clear-Pending Register bit puts the corresponding pending interrupt in the
inactive state. It is also written with the interrupt source ID to mask it. The following interface can be
static inline void NVIC_ClearPendingIRQ(IRQn_Type IRQn);
4. Configure the interrupt priority
NVIC interrupts are prioritized by updating an 8-bit field within a 32-bit register (each register
supporting four interrupts). Priorities are maintained according to the ARMv7-M prioritization
scheme. The following interface can be used directly:
static inline void NVIC_SetPriority(IRQn_Type IRQn,uint32_t priority);
5. Enable the interrupt at peripheral level
6. Enable the interrupt at NVIC level
The interrupt source can be enabled, both on the peripheral (in a mode register usually) and in the
Interrupt Set-Enable Register (ISER) of the NVIC. On the side of NVIC, the following interface can
be called directly:
static inline void NVIC_EnableIRQ(IRQn_Type IRQn);
Refer to core_cm7.h for more interfaces about NVIC which can be used directly.
Atmel AT12874: Getting Started with SAM S70/E70 [APPLICATION NOTE]
Some questions I have are:
step 1, How do I re-implement the interrupt handler for PIOA? The default handler is "Dummy_Handler".
Would I just create a new handler function for PIOA and replace that function into the Dummy_Handler
void PIOA_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
also the interrupt handler is only mapped to PIOA_Handler at irq10. How would I assign this to a single port pin?
Any help here would be greatly appreciated.