Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

FreeRTOS with standby mode in STM32

Posted by Jakub on July 24, 2013
Hi,
I've got a question: is it possible to use Standby Mode in Idle Hook or in Tickless Idle Mode? In standby mode SRAM and register contents are lost except for registers in the Backup domain. But in the Backup registers one can store only 84 bytes of user application. I think it is too litle - because I will lose system stack, tasks stack, system variables etc. Am I right?

RE: FreeRTOS with standby mode in STM32

Posted by Richard on July 24, 2013
Correct - you cannot enter a sleep mode that loses the CPU context, or the saved context for any of the tasks.

Regards.

RE: FreeRTOS with standby mode in STM32

Posted by Jakub on July 24, 2013
ok, thans.
But how can I find a place in memory where OS stores its variables, tasks stacks etc? Because I think it is possible to use a Flash Memory (emulating EEPROM) to copy this data and restore it after wakeup.

RE: FreeRTOS with standby mode in STM32

Posted by Richard on July 24, 2013
You could use the linker script to force the data into a known memory section, then save that section. That is similar to how the FreeRTOS-MPU port works (it uses the PRIVILEGED_DATA and PRIVILEGED_FUNCTION macros to force function and variables into a linker section). Alternatively you would have to add some functions into the kernel code that gave you access to the addresses of file private data.

You would have to save all the file private data (static variables) from source/portable/tasks.c, and the stack of every task. The stacks will come from the heap, and where the heap memory comes from depends on if you are using heap_1, heap_2, heap_3 or heap_4.c (or your own memory manager).

Is there much to be gained between using the second lowest low power mode (which keeps the registers and RAM powered) and the lowest (which looses the register and RAM data)?

Is it possible just to store a little state information in flash, then just restart the system completely when the MCU comes out of sleep mode. When you boot the system you can read the state information out of flash to inform your application of what it was doing when it was shut down.

Regards.

RE: FreeRTOS with standby mode in STM32

Posted by Richard Damon on July 24, 2013
A mode which loses most of memory and keeps just a bit of info is intended to be used in a mode where the processor in effect "reboots" on wake up, and the application uses the saved info to restart from where it was instead of at the beginning again by saving the APPLICATION state. Each of your tasks (that need it) would need to be allocated space in the Non-volatile memory to save its state, and would restart base on it. This would NOT be a full stack dump, but the few key parameters needed to restart from the last key checkpoint.

Normally it takes long enough to "restart" the processor, and would require too much state to have this happen just because you are in idle. Normally it is done when all the tasks have completed their major work (so they don't need to save much state to resume), and you are going to be waiting for some significant event that might not happen for awhile, when the processor will drop into standby.

Normally a simple low power mode (which is easier to recover from) is used in the idle hooks.

RE: FreeRTOS with standby mode in STM32

Posted by Jakub on July 24, 2013
Many thanks for exhaustive answer. In the lowest power mode typical current consumption is around 10x lower.But I have to consider all pros and cons.
Regards

RE: FreeRTOS with standby mode in STM32

Posted by Richard Damon on July 24, 2013
You need to be carefulll not to get "milliwatt" wise but "watt" foolish, these ultra-low=power states do consume a lot less power than normal operation, but due to what is needed to recover from them, they might have a moderate wake-up cost in terms of power. If you are going to be waking up on the next timer tick, which you know will be happening soon, anyway, it can well be a net LOSS of power to go into a deep power-save mode.

I typically have the idle loop go into a very mild low-power mode, one which requires little (if any) operations to wake up from. When the application detects that it doesn't have anything to do now, and is waiting for a user command, it may go into a deeper sleep. The ultra low power modes like this are for when your device detects that it isn't being used at the moment, and can go totally asleep, waiting for something to wake it up to be used again.

RE: FreeRTOS with standby mode in STM32

Posted by Richard on July 24, 2013
Yes, that is why the tickles idle mode allows you to configure how long the expected sleep time should be before it considers going to sleep. It also provides pre and post sleep hooks to allow application specific processing - this is how the SAM4L and RX100 reference ports set their chip specific sleep mode.

Regards.

RE: FreeRTOS with standby mode in STM32

Posted by Jakub on July 24, 2013
Thanks again.
I just asked my question thinking about tickless idle mode.
Regards

RE: FreeRTOS with standby mode in STM32

Posted by Jakub on July 29, 2013
hi again,
I've go some questions regarding using FreeRTOS and deep sleep mode. So, I've got a FreeRTOS with tickless idle mode, I create two tasks, both blink led, with freq 0,5Hz and 1Hz. When idle task is executed, MCU goes into standby mode and then it loses content of its registers and RAM. As you said, after wakeup it's like rebooting, so I create tasks and start scheduler again. And my question is - when I restore (and update) number of ticks after wakeup - does the scheduler unblock (or "unsuspend") my tasks in correct time? What does scheduler need to correct work? only time (number of ticks) and state of tasks? I'm sorry in advance, maybe my questions are naive, but I tried to find such information and I didn't get it.

RE: FreeRTOS with standby mode in STM32

Posted by Richard Damon on July 30, 2013
I don't think FreeRTOS has any provisions built into it for "restoring" your state after a deep sleep (the problem is that FreeRTOS doesn't know enough about your tasks to know what to remember about them. Thus when you recreate your task, they are starting fresh. Your tasks need to look at the information saved in the non-volatile memory to restart themselves in their previous state (and somehow get that data saved before going to sleep).

As I said, deep sleep is NOT something to casually use to save power, but a deliberate decision in the code to shut down to be restored at a latter point, with only a need to save limited information across the shutdown.

RE: FreeRTOS with standby mode in STM32

Posted by Jakub on July 30, 2013
Ok, thanks


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists