How to retain a variable in RAM through reset?

How to retain a variable in RAM through reset?

The usual answer of “how to retain a variable in RAM through reset?” question in Arduino, AVR, PIC, STM32 or most other MCUs is to store that variable in FLASH, EEPROM or external memory like SPI flash or something like that. The solution can be something simpler than that if the reset is not coming from losing power (power on reset).

When do I need to Reset my microcontroller?

There are cases when I need to do a reset of the device by software. For example I have loaded the application image with the bootloader, and then I need to perform a reset of the microcontroller to do a restart. As a human user I can press the reset button on the board.

How to debug hardfault on an ARM Cortex-M MCU?

This can be done by setting bit 1 ( DISDEFWBUF) of the register to 1. For the Cortex M7, there is no way to force all stores to be synchronous / precise. This register only exists for Cortex-M7 devices. When an IMPRECISE error occurs it will at least give us an indication of what memory bus the fault occurred on 4:

What does the unstkerr flag on a MCU mean?

UNSTKERR – Indicates that a fault occurred trying to return from an exception. This typically arises if the stack was corrupted while the exception was running or the stack pointer was changed and its contents were not initialized correctly. IMPRECISERR – This flag is very important.

How to mitigate power failure programming issues using Eeram?

In this how-to article, we explore the use of I2C EERAM to save critical program variables when power fails and restore them when power returns to easily preserve program continuity. Power failures are inevitable. When power returns, your program restarts, but with the contents of all of the variables lost.

When do I need to retain RAM after a software reset?

The solution can be something simpler than that if the reset is not coming from losing power (power on reset). If the reset is coming from asserting the reset pin or triggering a Watchdog Timer or even calling a software reset command from code, then the RAM content should be retained after reset from an electrical point of view.

What happens when power goes out in Eeram?

Power failures are inevitable. When power returns, your program restarts, but with the contents of all of the variables lost. Often times, it would be advantageous to have critical values saved and made available when power returns. EERAM makes it easy to do just that.