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

Proper way to use long period timer

Hi teams,

During development, I need quite a long period timer for hours.

Searching for the subject, I found application timer can only handle few minutes because of 24bit register.

Is there other proper way to get longer timer?

Parents Reply Children
  • I couldn't tested the setting.

    In app_config.h, it already defined as 0, and if I changed it, compiler shows the following error.

    11> Compiling ‘model_common.c’
    11> In file included from ../../mesh/core/include/utils.h:46,
    11>                  from ../../models/model_spec/common/include/model_common.h:42,
    11>                  from C:\Users\firebird\Documents\SEGGER Embedded Studio for ARM Projects\nRF52\nRF5_SDK_for_Mesh\models\model_spec\common\src\model_common.c:38:
    11> ../../../nRF5_SDK/components/libraries/util/app_util.h:219:41: error: static assertion failed: "unspecified message"
    11> ../../../nRF5_SDK/components/libraries/util/app_util.h:242:62: note: in definition of macro '_SELECT_ASSERT_FUNC'
    11> ../../../nRF5_SDK/components/libraries/util/app_util.h:259:25: note: in expansion of macro 'STATIC_ASSERT_SIMPLE'
    11> ../../mesh/core/api/nrf_mesh_assert.h:99:37: note: in expansion of macro 'STATIC_ASSERT'
    11> C:\Users\firebird\Documents\SEGGER Embedded Studio for ARM Projects\nRF52\nRF5_SDK_for_Mesh\models\model_spec\common\src\model_common.c:66:1: note: in expansion of macro 'NRF_MESH_STATIC_ASSERT'
    Build failed

  • Ok, I see that the mesh models use the app_timer library. If you get static assert, the value you configurated is most likely not compatible with the mesh SDK. Did you try increasing APP_TIMER_CONFIG_RTC_FREQUENCY to 1 or 3?

    The other alternatives are to use a second RTC for the long-running timers and configure this with a higher prescaler value, or you can run a shorter repeating app_timer and increment a variable in the handler to keep track of how long it has been running.

  • APP_TIMER_CONFIG_RTC_FREQUENCY with non-zero is not working, as I tried.

    OK. I will try alternatives. Can you give me a link to the references that I can refer to?

    I need some clarification how to be notified when RTC overflow occurs, and etc.

    And, can I use secondary RTC without hardware modification?

  • I think, in your case the easiest way is to split a long interval into a series of shorter ones, every time decreasing a counter that holds remaining time. A single wakeup every few minutes won't affect battery life time.

  • I agree. Now I am reviewing app_timer.c and can find enough informations what I want to get.

    Thank you.

Related