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

FreeRTOS and RTC

Hello!
I used the "blinky_rtc_freertos" example and transferred ticksource from RTC to SYSTICK in "FreeRTOSConfig.h".
The application has stopped working. What am I doing wrong?

I use nRF52840, SEGGER Embedded Studio for ARM Release 4.12 Build 2018112601.37855 Windows x64, nRF5_SDK_15.2.0,
debug board PCA10056 1.0.0. WINDOWS 10 x64.

Thank you.

FreeRTOSConfig.h

Parents Reply Children
  • Hi,

    Valery said:
    Let me remind you that I do not use SD.

    SoftDevice or not does not really matter, but since you wrote "SoftDevice(yet)", I take it that you intend to use in in the future? Therefor it makes sense to me to mention it where it might be relevant.

    Valery said:
    implemented the alarm clock on RTC2, for waking up once a month.

    I do not see any reason for using a dedicated RTC for an alarm clock. That is a perfect example of where you want to use an app timer or FreeRTOS timer instead. The app timer library is essentially made to make it easier to make multiple virtual timers form a single physical RTC instance.

    Valery said:
    What should I do for a deep sleep app with FreeRTOS?

    What do you mean by deep sleep? Do you mean system off (where you need an external wakeup source), or do you mean system ON low power mode? As we are discussing waking up once a month, then I assume the latter. And in that case, you essentially just make a normal timer based on the RTC, for instance a app timer or a FreeRTOS timer directly (use xTimerCreate). Note that you may have to wake up more than once a month due to the wraparound time of the RTC, but that has no practical impact on average current consumption.

    In short, make a timer that times out regularly and keep track of time based on that. Other than that, go to system off low power mode (using something like __SEV(); __WFE(); __WFE();, and moving to sd_app_evt_wait when you introduce the SoftDevice.

  • Thank you for the detailed and quick response! 

    I want to minimize energy consumption, because I use battery power. And of course, under a deep sleep, I understand the absence of any processor actions, except for the RTC ticks 8 times per second(use MAX PREACALER). Therefore, I want to stop the FreeRTOS and all interrupts, except RTC2.

  • Hi,

    We always assume that the product is battery powered, as that is the typical use case for nRF devices. It is simply not possible to only use the RTC, as it need the LF clock to function. The LF clock and needed regulator will effectively consume about 2.5 µA on the nRF52832. This includes the RTC. This is the typical sleep current for any power optimized design with the nRF52840.

    Essentially what you need to do is what I suggested my previous post: use a RTC in some way (either directly or via a SW library) and wake up as seldom as possible to do timekeeping before you go back to sleep (due to 24 bit RTC wrap around time being too long for 1 month sleep durations, regardless of prescaler configuration).

Related