Disabling FreeRTOS and entering standby mode
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-03-07 01:43 PM
I am using STM32L053 and Keil IDE. I have imported FreeRTOS from CubeMX. Is there a way I could disable the FreeRTOS and enter into standby mode? Then, wake up on GPIO signal (external interrupt). And when I wake up, I should be able to start from scratch inside the superloop and be able to start the FreeRTOS again. Any suggestions and inputs is much appreciated.
Thanks,
Harsha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-03-07 02:07 PM
Isn't this covered in the FreeRTOS documentation?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-03-07 03:58 PM
That is exactly what the tickless idle mode in FreeRTOS enables.
https://www.freertos.org/low-power-tickless-rtos.html
andhttps://www.freertos.org/Atmel_SAM4L-EK_Low_Power_Tick-less_RTOS_Demo.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-03-07 07:20 PM
What you describe is best done in stop mode. You can halt the RTOS scheduler, preserve SRAM and peripheral settings, set up a wakeup and resume at some point later on. You'll need to update the RTOS tick counter, as described in tickless mode.
Standby mode cuts power to SRAM and peripherals. It resets on a wakeup from an RTC backup power domain source. You'll have to go through initialization and RTOS startup, but there is a standby flag to inform your app it's a wakeup instead of a cold start.
If the idle time is only a short period, a few seconds, use the sleep mode to stop the instruction clock instead. It resumes very quickly and is easy to implement in FreeRTOS.
If you are concerned about power management, look at how low you can run the instruction clock frequency. That, and lowering the Vcore voltage, makes a large difference in power consumption. On STM32L0 controllers I try to keep it at 2Mhz clock (MSI) and Vcore down to 1.2V. Most times you really don't need that peak 32 MHz clock speed.
Jack Peacock
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-03-08 08:45 AM
Hi Andrew,
The document provides information about vTaskSuspendAll() API Function. This only suspends the context switching but keeps the interrupts alive. My aim is to start fresh once the system is woken up on a GPIO interrupt and not resume the scheduler.
I did find vTaskEndScheduler() to be relevant to what I am looking for but I am wondering how to write an exit function in
vPortEndScheduler () specific to my MCU that helps me stop the kernal tick.
Thanks,
Harsha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-03-08 09:56 AM
Hi Jack,
Thank you so much for your response. Your inputs are valuable. I would like to throw some more light on what exactly I am looking for.
'You can halt the RTOS scheduler, preserve SRAM and peripheral settings, set up a wakeup and resume at some point later on. You'll need to update the RTOS tick counter, as described in tickless mode.'
-- I would like to stop the RTOS completely instead of halting it, and then resume on wakeup. Because the system would be in idle state most of the time. Almost 90% of the time, it should be in power saving mode. So ideally, I do not want tickless mode as it would consume power by running the clock at lower rate.
'If the idle time is only a short period, a few seconds, use the sleep mode to stop the instruction clock instead. It resumes very quickly and is easy to implement in FreeRTOS.'
-- For my application, power consumption should be as minimum as possible. And idle time would be a few hours. Wake up time is not a concern. Aim to to consume least power.
'On STM32L0 controllers I try to keep it at 2Mhz clock (MSI) and Vcore down to 1.2V. Most times you really don't need that peak 32 MHz clock speed'
-- I am using 2Mhz and 1.5V Vcore. If I choose 1.2V, my ADC sampling might be effected. I will take a look into it.
As of now, my approch would be to
1) Stop the scheduler (i.e. Delete all tasks and disable the kernal tick)
2) Go to Standby mode
3)Restart the scheduler upon wakeup.
2nd and 3rd steps should be straight forward. Disabling the FreeRTOS completely is what I am not able to figure out. i found
https://www.freertos.org/a00133.html
to be relevant to what I am looking for but I am wondering how to write an exit function invPortEndScheduler () specific to my MCU that helps me stop the kernal tick.