Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

sdk16.0 ppi example, cpu waste with an empty timer handler

hello Nordic

something is not clear to me regarding the use of timer and ppi to toggle a pin 

1. to my understanding the whole idea of using the ppi is to avoid CPU intervention, but if i must have a handler as the 'nrf_drv_timer_init()' demands then what is the point, i can toggle the pin in the timer handler itself, what am i missing ??

2. why putting a NULL as timer handler in 'Release' mode of debug works fine but in debug the assertion force me to use a timer handler ?? 

hope to read you soon

best regards

Ziv

Parents
  • Hi Ziv,

    It is possible to use the timer driver without interrupts, but the way the driver is designed to need to provide a event handler function even if it is not used, when you call nrf_drv_timer_init(). However during subsequent configuration you can decide if you want to use interrupts for specific events or not. So for instance if you configure an event on a compare using nrf_drv_timer_extended_compare() the last parameter is a boolean that configures if you want a interrupt or not. If that is set to false the event can be used to trigger PPI, but there will never be an interrupt.

    The result of this is that you always need to provide a dummy timer event handler (which I agree is not elegant) but it is never called unless you want it to, so it does not cause any additional CPU usage.

    Einar

Reply
  • Hi Ziv,

    It is possible to use the timer driver without interrupts, but the way the driver is designed to need to provide a event handler function even if it is not used, when you call nrf_drv_timer_init(). However during subsequent configuration you can decide if you want to use interrupts for specific events or not. So for instance if you configure an event on a compare using nrf_drv_timer_extended_compare() the last parameter is a boolean that configures if you want a interrupt or not. If that is set to false the event can be used to trigger PPI, but there will never be an interrupt.

    The result of this is that you always need to provide a dummy timer event handler (which I agree is not elegant) but it is never called unless you want it to, so it does not cause any additional CPU usage.

    Einar

Children
No Data
Related