1

I am wondering what happens for variables & their content after STM32 mcu enters low power mode or exit from it? for example in sleep mode or standby. do their content remove or survived?

best!

  • Low power modes woukd not be very useful if RAM contents got lost:) – Martin James Aug 31 '21 at 09:45
  • 1
    Everything is described in the Reference Manual. Every model has different memory layout and you may set to keep some RAM areas or not. – 0___________ Aug 31 '21 at 09:45
  • @0___________ do you know of many microcontroller low-power states where the internal RAM loses data? I have not seen any in my experience. It is interesting that you use systems where reinitializing RAM is practical:) That is not so much a low-power mode as 'switch it off and turn it on again'. – Martin James Aug 31 '21 at 09:59
  • @MartinJames `do you know of many microcontroller low-power states where the internal RAM loses data?` yes, all STM32s if the programer decides that he wants to. – 0___________ Aug 31 '21 at 10:14

1 Answers1

0

You can preserve or not - it is usually (depending on the mode) up to the programmer. Memory consumes power so very often it is more energy efficient to reinitialize RAM after wake up (I do it sometimes in my projects)

Example: STM32L476:

enter image description here enter image description here

0___________
  • 60,014
  • 4
  • 34
  • 74
  • So does that mean that SRAM *can* only be lost in Standby mode? – Weather Vane Aug 31 '21 at 10:14
  • @WeatherVane no. You have control over it. if you disable the SRAMx clock it will switch off. – 0___________ Aug 31 '21 at 10:16
  • I see, note 3. So is the answer to the Q "Varaibles survive unless the programmer *specifically disables* SRAM"? Apart from Standby, where "disable" is the default. – Weather Vane Aug 31 '21 at 10:18
  • Thanks a lot! is there any way to force compiler to use for example SRAM1 for storing a variable when I declare it?(By this way I want to turn on only one of two SRAMs). – Amin-nano-sys Aug 31 '21 at 10:40
  • @Amin-nano-sys, Of course, there is. Learn linker scripts. – 0___________ Aug 31 '21 at 12:59
  • @0___________, Would you leave a link or something like that for me to learn linker script for STM32L433 mcu? – Amin-nano-sys Sep 01 '21 at 05:24
  • @Amin-nano-sys google it - ld linker scripts. You have plenty resources. They are general, platform independent. – 0___________ Sep 01 '21 at 07:45
  • If you have a default CubeIDE project, look at the linker script file, it will be named something like "STM32F410RBTx_FLASH.ld". If you want something fast and easy, just declare only one RAM space = SRAM1, so the linker will use only SRAM1. You must know the location of this RAM, and its length. You can also, next step, customize your code and this file to put all functions and variables where you want, it's really powerful. – svalsesia Sep 02 '21 at 12:16