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

FreeRTOS RTC Prescaler Produces Incorrect Time

In SDK 11 the FreeRTOS port has the following line is declared in portmacro_cmsis.h

#define portNRF_RTC_PRESCALER  ( (uint32_t) (ROUNDED_DIV(configSYSTICK_CLOCK_HZ, configTICK_RATE_HZ) - 1) )
In the above example configSYSTICK_CLOCK_HZ is 32.768kHZ and configTICK_RATE_HZ is 1.0kHz.

According to the nRF52 datasheet (section 25.2) the above prescaler calculation is correct. When I toggle an I/O to measure the timing I am getting ~973us, not 1.007ms as I would expect given the prescaler equation. If I remove the - 1 from the above define then I get an output of 1.007ms.

Thanks

Related