How to get the memory state of SRAM on power up?

If you want to read the SRAM content right at power up and try to do that in C or C++ you are going to have some trouble....particularly on an embedded type system....because some RAM content may be zeroed at startup and other parts may be used for initial stack content. There are also some high reliability embedded applications where ECC is used for the RAM and this needs to be initialized by writing, in its entirety, to make sure all the check bits are set properly before any of the RAM is read. A read with an invalid ECC check can result in system reset or error hang.

This memory zeroing is typically done inside the "startup code" that is the first thing to execute when the MCU comes out of reset and fetches its first execution address from the reset vector. "Startup code" is typically written in the native assembly language of the MCU for ease of coding at the "bare metal" level of processor resource access. There are also performance reasons for the use of the assembly language.

Startup code packages that come with various C/C++ tool sets are often complex code because the code will be highly parameterized with conditional directives to deal with a multitude of different possible hardware configurations. I mention this because you will have to deal with this based upon what I state in my next paragraph.

To be able to read the SRAM content right out of the reset vector at power on you are going to have to either modify the "startup code" or add a new layer of "bare metal" code between the reset vector and when the startup module takes control.

Tags:

Power

Sram