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

Found a Bug in the PPI Example

Hi, I found a bug in the PPI example in the nRF5 SDK v14.0.0 .

In "<SDK_ROOT>/examples/peripheral/ppi/main.c", the following function has an error:

static void timer2_init(void)
{
    // Generate interrupt/event when half of time before the timer overflows has past, that is at 1,3,5,7... seconds from start.
    // Check TIMER1 configuration for details
    // now the overflow occurs every 0xFFFF/(SysClk/2^PRESCALER)
    // = 65535/31250 = 2.097 sec */
    nrf_drv_timer_config_t timer_cfg = NRF_DRV_TIMER_DEFAULT_CONFIG;
    timer_cfg.frequency = NRF_TIMER_FREQ_31250Hz;
    ret_code_t err_code = nrf_drv_timer_init(&timer2, &timer_cfg, timer_event_handler);
    APP_ERROR_CHECK(err_code);

    nrf_drv_timer_extended_compare(&timer2, NRF_TIMER_CC_CHANNEL0, 0x7FFFUL, 
NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, false);
}

TIMER2 should generate a CC event every odd second, but actually generates one every second due to the NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK mask, when using 0, it is working well.

BTW, I found this bug using an emulator, if you are interested, you can check out the blog post I wrote about it.

Related