ISR on rising edge with registers

Hey everybody,

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!

// NVIC enable
  NVIC_EnableIRQ();

  // PIO_IMR = PIO_IER
  PIOC->PIO_IER = PIO_PC12;
  PIOC->PIO_IMR = PIO_PC12;
  
  // enable PIO CLK

  //  PIO_AIMER -> additional interrupt
  PIOC->PIO_AIMER = PIO_PC12;
  PIOC->PIO_AIMMR = PIO_PC12;

  // PIO_ESR -> rising edge
  PIOC->PIO_ESR = PIO_PC12;
  
  // PIO_REHLSR -> rising edge
  PIOC->PIO_REHLSR = PIO_PC12;

Okay I think it's: NVIC_EnableIRQ(PIOC_IRQ12);

Normally, for CortexM, there's an n at the end for interrupt handlers

NVIC_SetPriority(TIM7_IRQn, 18);
NVIC_EnableIRQ(TIM7_IRQn);

Oh I thought the n was a placeholder for the pin number. What does TIM7 stand for? Or is there a table where I can look up all the ISR names?

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]();
  }
  }

*/

Yes, that's right.