Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF5_SDK_17.0.2 When FreeRTOS is used, how to sleep for a specific time, say 30 minutes, in system on low powermode

  There are more than one task, after completing the periodic work,the 52832 module should enter system on low power mode,sleep 30 minutes,then wake up and continue with the periodic work.

  Any suggestions would be appreciated. Thanks.

Parents
  • Hi,

    If you have enabled the tickless idle functionality, then you have asked the RTOS to decide when to sleep. If you want to control the sleep cycle of your device, then you should NOT enable the tickless idle in your FreeRTOSConfig.h file.

    With Tickless Idle enabled

    1. Create a timer for 30 minutes (register a callback) inside a task (Lets say Task A) and start the timer.
    2. Suspend your task just after starting the timer. If there are no other tasks that are active, then the idle task will be called and will make the chip go to sleep due to the tickless feature.
    3. After 30 minutes the RTOS will wake the chip up and call your callback registered in the timer, just resume the task that you suspended before sleep.

    Without tickless enabled

    You need your application to control its own sleep cycle.

    1. Enable application idle hook and call the sleep function (__SEV,__WFE,__WFE) inside the application idle hook handler.
    2. just call vTaskDelay(30 * 60 * 1024). This will block the task for 30 mintues and if no other tasks are running, your idle hook handler will make the chip go to sleep. If any interrupt woke the chip before 30 minutes expired, then the idle hook handle will be called again to make the chip go to sleep. After the minutes, the delay will expire and your task is unblocked so idle hook handler will not be called until every task is blocked
Reply
  • Hi,

    If you have enabled the tickless idle functionality, then you have asked the RTOS to decide when to sleep. If you want to control the sleep cycle of your device, then you should NOT enable the tickless idle in your FreeRTOSConfig.h file.

    With Tickless Idle enabled

    1. Create a timer for 30 minutes (register a callback) inside a task (Lets say Task A) and start the timer.
    2. Suspend your task just after starting the timer. If there are no other tasks that are active, then the idle task will be called and will make the chip go to sleep due to the tickless feature.
    3. After 30 minutes the RTOS will wake the chip up and call your callback registered in the timer, just resume the task that you suspended before sleep.

    Without tickless enabled

    You need your application to control its own sleep cycle.

    1. Enable application idle hook and call the sleep function (__SEV,__WFE,__WFE) inside the application idle hook handler.
    2. just call vTaskDelay(30 * 60 * 1024). This will block the task for 30 mintues and if no other tasks are running, your idle hook handler will make the chip go to sleep. If any interrupt woke the chip before 30 minutes expired, then the idle hook handle will be called again to make the chip go to sleep. After the minutes, the delay will expire and your task is unblocked so idle hook handler will not be called until every task is blocked
Children
Related