How can we decrease the resolution of the timer to 500 ms in SDK 14? The minimum resolution I could get to was 1 ms by changing the APP_TIMER_CONFIG_RTC_FREQUENCY macro to 31.
Thanks
Atul
How can we decrease the resolution of the timer to 500 ms in SDK 14? The minimum resolution I could get to was 1 ms by changing the APP_TIMER_CONFIG_RTC_FREQUENCY macro to 31.
Thanks
Atul
The RTC peripheral has a 12 bit prescaler. So the max value for prescaler will be (2^12) - 1 = 4095. This will give you a counter resolution of 125 ms with an overflow of 582.542 hours.
If you want the l̶o̶w̶e̶s̶t̶ highest counter resolution, you can set the prescaler (APP_TIMER_CONFIG_RTC_FREQUENCY) to 0. This will give you a counter resolution of 30.517 us and an overflow of 512 seconds.
The counter resolution of 30.517 us is the highest resolution right, not the lowest one.
Is there any way in which I can get a resolution of 500 ms? And even if I make do with the 125 ms resolution, where should I change the PRESCALER register? I didn't see any such command in the documentation of SDK 14. I could change the APP_TIMER_CONFIG_RTC_FREQUENCY macro, but in the description, there are some values provided to us, and I suppose, only those can be used as the possible values of the macro. I am attaching the code from the sdk_config file.
// <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 31 #endif
The app_timer library sets the prescaler for you. Look at the rtc1_init(..) routine in app_timer.c
The APP_TIMER_CONFIG_RTC_FREQUENCY is the prescaler value for app_timer library.
static void rtc1_init(uint32_t prescaler) { NRF_RTC1->PRESCALER = prescaler; NVIC_SetPriority(RTC1_IRQn, RTC1_IRQ_PRI); }
This is called by app_timer_init(...)
ret_code_t app_timer_init(void) { ..... rtc1_init(APP_TIMER_CONFIG_RTC_FREQUENCY); .... }
Cool. Got it! But 500 ms resolution is impossible then? 125 ms is the minimum we could get?
Cool. Got it! But 500 ms resolution is impossible then? 125 ms is the minimum we could get?
Yes, I believe so. What is the reasoning for having a 500 ms resolution? Just curious!
Want to send the timestamp values in the advertisement packets and I don't want to have large timer values as the packet sizes are very small. About half a second resolution would have been pretty good. But, I guess I will try to work with 125 ms.