0
\$\begingroup\$

I am new to MCU programming, I use STM32, C language, IAR IDE, HAL. I need to erase SRAM of the MCU STM32L071RZT6 when the "Erase" button is clicked. How can it be done? Will it cause app crash? Can memset() be used for that?

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Normally you just write 0's (or some other known value) to the memory. Typically, your code will be in Flash ROM so it can still run after the RAM is erased. \$\endgroup\$ Commented Dec 12, 2017 at 4:43

1 Answer 1

1
\$\begingroup\$

I suspect your question is badly formulated and that is not what you want, but I will answer what you have asked for.
Yes you can clear all your SRAM but you have to do some very careful coding as it will destroy your stackpointer contents. As such you can NOT call another function as the return address will have disappeared, together with the values of all your variables and intialised structures.
If you do use memset() your CPU will start running from address 0 when it tries to return.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.