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

Using Timer 2 in GPIOTE sample on NRF SDK 11

I was playing around with the gpiote example under exaples/peripheral/gpiote. The example uses a timer, ppi, and gpiote to blink an led. By default, the app uses Timer 0 and that works well. If i were to change switch to Timer 1 or Timer 2 it doesn't seem to work. I did change the nrf_drv_config.h file to enable those extra timers. Is there something else I have to do to use either Timer 1 or Timer 2?

Parents
  • The value given in led_blinking_setup:nrf_drv_timer_extended_compare ->200 *1000 = 30D40 does not fit into 16-bit timer1 and timer2.

    Change the values in nrf_drv_config.h to

    #define TIMER1_CONFIG_FREQUENCY    NRF_TIMER_FREQ_125kHz
    #define TIMER2_CONFIG_FREQUENCY    NRF_TIMER_FREQ_125kHz
    

    and instead of writing 200 *1000 in led_blinking_setup:nrf_drv_timer_extended_compare you need to write 125000/2 = 0Xf424. So your LED will blink every half second.

Reply
  • The value given in led_blinking_setup:nrf_drv_timer_extended_compare ->200 *1000 = 30D40 does not fit into 16-bit timer1 and timer2.

    Change the values in nrf_drv_config.h to

    #define TIMER1_CONFIG_FREQUENCY    NRF_TIMER_FREQ_125kHz
    #define TIMER2_CONFIG_FREQUENCY    NRF_TIMER_FREQ_125kHz
    

    and instead of writing 200 *1000 in led_blinking_setup:nrf_drv_timer_extended_compare you need to write 125000/2 = 0Xf424. So your LED will blink every half second.

Children
Related