Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

Starting timers from GPIOTE with the same or higher interrupt level..

I am encountering an unusual behavior when I stop/start app_timers from the GPIOTE IRQ.  I am implementing a debounce procedure from a GPIO interrupt .I find the timer callback is sometimes performed but not always.  If I reconfigure the GPIOTE interrupt to be lower priority than the APP_TIMER_CONFIG_IRQ_PRIORITY the timer works as expected.  If I configure the GPIOTE to be the same or  higher priority than the RTC/APP_TIMER interrupt then the scheduler is sometimes not called.  When it is not called, I find the timer is showing as active, but it does not appear to be in the linked list of timers. 

Is there a requirement for app_timer_start/app_timer_stop functions to be called from a lower IRQ priority than the RTC / APP_TIMER IRQ priority? 

We are using app_timer2.

This is with NRF5 SDK 17.0.2.

  • Hello,

    I am not quite sure about your setup. Are you implementing your own debounce, or are you using the debounce from the app_button library? 

    Either way, if you are working with GPIOTE interrupts, and you are waiting in an interrupt for a timer to time out, you need to either return from the interrupt, to allow the app_timer interrupt to receive CPU access, or you need to make sure the app_timer has a higher interrupt than the GPIOTE interrupt. These are typically configurable in sdk_config.h. I am not sure what chip and SoftDevice you are using, but it is more or less the same in all softdevice versions. You can look here for what interrupt levels you can use, and which ones that are reserved for the SoftDevice.

    Best regards,

    Edvin

Related