This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to write GPIOTE interrupt?

Hi,

i need to stop one of my Timer at the falling edge of a Pin. So i need a gpiote_interrupt, is this right? Can someone help me how i can do this? if i write something like GPIOTE_IRQHandler ( ) it doesn't work.

best regards Nils

Parents
  • Hi Nils

    The following steps are required to use interrupts:

    1. Tell the peripheral which events should generate interrupts, something like this:

    NRF_GPIOTE->INTENSET = GPIOTE_INTENSET_IN0_Msk;

    1. Enable the peripheral in the NVIC (if you use the SoftDevice use the sd_nvic_EnableIRQ() instead):

    NVIC_EnableIRQ(GPIOTE_IRQn);

    1. Implement the interrupt handler, and remember to check/clear the event:
    void GPIOTE_IRQHandler(void)
    {
        if(NRF_GPIOTE->EVENTS_IN[0] != 0)
        {
            NRF_GPIOTE->EVENTS_IN[0] = 0;
            
            // Add your code here
        }
    }
    

    On a side note, have you considered using the PPI to stop the timer automatically on the GPIOTE event? Then you might not need the interrupt at all.

  • Hi Nils, I used the example code "pin_change_int_example" at SDK v6.1.0(softdevice v7.1.0) for gpio interrupt testing, it didn't work at all. I have tried the example what you mentioned, it didn't work too. Can you have any advices for me? Best regards. Stanley

Reply Children
No Data
Related