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

Usage of RTC0 as time basis (system time) possible?

Hello everybody,

RTC0 is used by the SoftDevice. Is it possible to use the current RTC0 counter value as a system time, so that RTC1 doesn't have to run additionally? For this purpose, RTC0 would have to run continuously.

My goal is to save timestamps for certain events (e.g. a interrupt through a GPIO pin, or a BLE event) and measure time difference between these events.

This is why I need to know if the RTC0 counter value can be accessed without any problem, and if the RTC0 may be stopped/disabled at any time after the SoftDevice has been enabled (using SOFTDEVICE_HANDLER_INIT()):

  • Is RTC0 disabled on S110 when there is no advertising and no connection in progress (so the stack is completely idle)?

  • Is RTC0 disabled on S120 when there is no scanning and no connection in progress (so the stack is completely idle)?

  • Is the RTC0 counter value reset at any time? E.g. when switching from Advertising mode to Connection mode, or restarting Advertising with a different interval.

One more question regarding energy consumption: Will there be a different sleep energy consumption with the S110 stack whether advertising/connection is active or the SoftDevice is idle? Sleep mode is entered with sd_app_evt_wait() in both cases. This question is related to my concern that RTC0 might be switched off when the SoftDevice is idle. (We intend to measure the sleep energy consumption without any wakeup because the measurement resolution would be too low otherwise.)

Parents
  • Hi puz_md,

    i have the some problem. I'm thinking to use a RTC2, even if RTC0 or RTC1.

    What do you think about that?

    Thanks, Anna

  • Hi Anna,

    I was using RTC0 only to get some timestamps for short time interval measurements. As RTC0 was already running, I didn't want to waste ressources and energy for using one more timer. Although this strategy worked very well in my prototypes, I would not suggest to use RTC0 in your final (series) product. Just like Stefan mentioned, there is no guarantee thet RTC0 will always be running in an endless loop.

    Which timer would be the best choice for your project depends on what you want to do with it. The RTCs are very energy efficient, but they are only 24 bits wide. Maybe the normal timers (which are 32 bits wide and provide more features) would fit your requirements better. Especially if you need higher precision timing = fast input clock, which would need the high frequency crystal to be activated (needs more energy in sleep phases).

    Just take a look at the nRF Product Specification (chapters TIMER and RTC), I think they have a very good documentation of their hardware.

    If you just used RTC0 like I did, you might want to use RTC1 or RTC2 (doesn't really matter which instance, as long as it is not used by other software modules) to keep the changes in code down to a ninimum. I encapsulated my RTC0 access into a small module / function called getTimestamp(). This way, I can easily replace RTC0 with RTC1 later.

    Good luck, Michael

Reply
  • Hi Anna,

    I was using RTC0 only to get some timestamps for short time interval measurements. As RTC0 was already running, I didn't want to waste ressources and energy for using one more timer. Although this strategy worked very well in my prototypes, I would not suggest to use RTC0 in your final (series) product. Just like Stefan mentioned, there is no guarantee thet RTC0 will always be running in an endless loop.

    Which timer would be the best choice for your project depends on what you want to do with it. The RTCs are very energy efficient, but they are only 24 bits wide. Maybe the normal timers (which are 32 bits wide and provide more features) would fit your requirements better. Especially if you need higher precision timing = fast input clock, which would need the high frequency crystal to be activated (needs more energy in sleep phases).

    Just take a look at the nRF Product Specification (chapters TIMER and RTC), I think they have a very good documentation of their hardware.

    If you just used RTC0 like I did, you might want to use RTC1 or RTC2 (doesn't really matter which instance, as long as it is not used by other software modules) to keep the changes in code down to a ninimum. I encapsulated my RTC0 access into a small module / function called getTimestamp(). This way, I can easily replace RTC0 with RTC1 later.

    Good luck, Michael

Children
No Data
Related