Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

Someone please explain app_timer_cnt_get() and how to work with i

As usual the documentation gives me nothing more than what I can find in the source code h-files.

I am trying to find one place where I can get the information I need to configure the RTC so that I know what the count = app_timer_cnt_get() value is. I think its default is 32768 ticks per second but I am not sure. I think that can be reduced by setting some parameter in the sdk_config.h file but I don't know which one. There is also some parameter APP_TIMER_MAX_CNT_VAL which tells the maximum number of counts before the clock cycles back to 0 (in app_timer.h. There are hundreds of items to look for and searching for 'RTC' doesn't cut it as I have those set to 0 (not enabled) and this function still works fine.

Thanks.

Parents
  • Hello,

    I am trying to find one place where I can get the information I need to configure the RTC so that I know what the count = app_timer_cnt_get() value is.

    You should not configure the RTC peripheral directly if you are intending to use the app_timer library - then you should only use the options provided by the app_timer library, to avoid breaking any of its functionality.
    As you have seen from the documentation the call to app_timer_cnt_get only returns the current value of the RTC1 Counter. The APP_TIMER_MAX_CNT_VAL define does indeed set how high this COUNTER will count before resetting. The frequency of the counting is based on the frequency of the RTC1 instance, which can be configured with the APP_TIMER_CONFIG_RTC_FREQUENCY define in sdk_config.

    Best regards,
    Karl

Reply
  • Hello,

    I am trying to find one place where I can get the information I need to configure the RTC so that I know what the count = app_timer_cnt_get() value is.

    You should not configure the RTC peripheral directly if you are intending to use the app_timer library - then you should only use the options provided by the app_timer library, to avoid breaking any of its functionality.
    As you have seen from the documentation the call to app_timer_cnt_get only returns the current value of the RTC1 Counter. The APP_TIMER_MAX_CNT_VAL define does indeed set how high this COUNTER will count before resetting. The frequency of the counting is based on the frequency of the RTC1 instance, which can be configured with the APP_TIMER_CONFIG_RTC_FREQUENCY define in sdk_config.

    Best regards,
    Karl

Children
Related