I want to use the built-in function to generate an interrupt on a rising-edge detection on Pin12 on Port C. I have the following code but couldn't figure out what goes in the brackets of NVIC_EnableIRQ(). I also dont know how to setup the ISR, I only found examples for T/C like:
void TC0_Handler()
{
// ISR Code
}
Also the datasheet states that you have to enable the PIO CLK, how does that work? and if you could check my setup code as well that would be great. Thanks!
The datasheet of the MCU should have a table describing all the interrupts, normally under section Nested Vectored Interrupt Controller (NVIC). From there, its just a matter of adding _IRQn when coding for the ISR
To trigger an interrupt on any broken out PIO pin (e.g. PC12, Arduino DUE pin 51), you first want to alter Winterrupts.c has explained in Reply #5 of this topic so that you can write your own PIO interrupt handler:
Are you talking about this part? Do I just have to add it at the top? And would it be PIOC instead of PIOA in my case?
// Winterrupts.c has to be modified since attachinterrupts is too slow
// ...package/arduino/hardware/sam/1.6.6/cores/arduino/Winterrupts
/*
void PIOA_Handler(void) __attribute((weak)); // <***** Add this attribute before each PIO Handler
void PIOA_Handler(void) {
uint32_t isr = PIOA->PIO_ISR;
uint32_t i;
for (i=0; i<32; i++, isr>>=1) {
if ((isr & 0x1) == 0)
continue;
if (callbacksPioA[i])
callbacksPioA[i]();
}
}
*/