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

RTC0, RTC1 and the app_timer with SoftDevice

Hi all,

I'm a bit confused. After going through available documentation, I thought I had understood that RTC0 was used by the SoftDevice, but that RTC1 was available to use how I liked. After going through the ble_app_template example, it turns out that the use of app_timer is necessary for the ble stack to work (used by the Connection Parameters module), thus making RTC1 unavailable for custom configuration. Is it always the case or just the for this example ?

Are there other requirements on app_timer for the ble_stack to work ? (Maximum prescaler value for instance)

This leads me to another question: if I have to use the app_timer, is there a way to specify priority levels of different timer timeout functions ? My application requires to keep track of the current time very precisely and I was planning to use RTC1 exclusively for that purpose.

Thanks !

  • It is correct that the softdevice itself only requires RTC0, but as you've seen, some of the SDK modules use RTC1, most notably app_timer, which is again used by the connection parameters module.

    It is perfectly possible to build an application without app_timer, but it will require some modifications to the SDK modules that uses it. You should however note that the connection parameters module isn't strictly required, since you can send connection parameter update requests manually by using the softdevice API directly. All modules using app_timer are optional, and you can just avoid using them. It is of course also an option to modify app_timer to cope with both your needs while still maintaining an API that the other modules can use. Exactly how to solve this is an application choice.

    There isn't any way to run different timers with different priorities with the current app_timer implementation.

  • I am also looking for a way to take control over RTC1.

    Is there somewhere an explanation or an example of how to manually handle the connection parameter module?

    I also notice that auth_status_stracker also uses the app_timer. How do I manually work with that?

    Thanks.

  • I have a similar requirement to Cyril. I'm developing for both nRF51822 and nRF52810. For now I'm testing with an nRF52 dev kit (nRF52810 emulation) using SDK nRF5_SDK_15.3.0_59ac345. 

    As Timor has asked, is there somewhere an explanation or example of how to manually handle the connection parameter module in order to eliminate dependence on app_timer?

    It seems like ble_conn_params.c uses app_timer (and hence, RTC1) during the BLE connection process and only under erroneous conditions (if (!p_instance->params_ok)). I've found that once a BLE connection has been established, RTC1 is stopped and its counter value is 0, and remains so.

    I'd like to use RTC1 with prescaler 327, which would give me 100 Hz resolution and 46+ hours before overflow. Can I access/use RTC1 with the nrfx_rtc driver after BLE connection is established? If yes, then I can set its prescaler to 327 and start (NRF_RTC1->TASK_START), and then NRF_RTC1->COUNTER to read the value to get the number of 10.009574 ms ticks since RTC1 started. After disconnecting BLE, I would stop RTC1 and set its prescaler back to 0. Reasonable?

    Advanced thanks for any guidance.

    -Tim

  • I also have the same requirements as Cyril and Tim, I want to use the RTC1 manually for timing and not use app_timer. 

    I made a workaround for conn_params and I can use RTC1 in a timeslot.

    But now I want to use RTC1 without softdevice, that works but if I want to re-enable the softdevice again I get an error that some device is already in use (RTC1)

    So this code at the startup in main fails when I enable RTC1:

    // startRTC();
    syncRadios();


    ble_stack_init();

    I though the softdevice didn't need RTC1 ?

Related