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

nRF52840 SDK16 - What is the practical purpose of prescaler in app_timer?

Hi everyone,

I know that I can configure the resolution of app_timer by adjusting the prescaler form sdk_config.h

// <o> APP_TIMER_CONFIG_RTC_FREQUENCY  - Configure RTC prescaler.
 
// <0=> 32768 Hz 
// <1=> 16384 Hz 
// <3=> 8192 Hz 
// <7=> 4096 Hz 
// <15=> 2048 Hz 
// <31=> 1024 Hz 

#ifndef APP_TIMER_CONFIG_RTC_FREQUENCY
#define APP_TIMER_CONFIG_RTC_FREQUENCY 0
#endif

However, what is the practical purpose of prescaler? Could give me an example where is usefull to adjust the prescaler and change the timer's resolution?

Thanks

Nick

Parents
  • The prescaler give the option of reducing resolution in return for increasing the amount of time between overflows/wraparound.

    If you are trying to timestamp something which happens quite slowly, a lower frequency clock (e.g. 1024 Hz) is just as fit for the purpose as the fastest setting (32768Hz) - for example, if you are recording the opening and closing of a door.

    When your ticks happen 1024 times per second, a 16-bit timer value will overflow and wrap around every 64s, whereas a 32,768Hz clock will overflow/wrap every 2s.

Reply
  • The prescaler give the option of reducing resolution in return for increasing the amount of time between overflows/wraparound.

    If you are trying to timestamp something which happens quite slowly, a lower frequency clock (e.g. 1024 Hz) is just as fit for the purpose as the fastest setting (32768Hz) - for example, if you are recording the opening and closing of a door.

    When your ticks happen 1024 times per second, a 16-bit timer value will overflow and wrap around every 64s, whereas a 32,768Hz clock will overflow/wrap every 2s.

Children
Related