Skip to main content
shotkyy
Associate
November 26, 2019
Question

why does the microcontroller lose the program when power is off?

  • November 26, 2019
  • 6 replies
  • 2628 views

How can I avoid this?

This topic has been closed for replies.

6 replies

Ozone
Principal
November 26, 2019

When the code is loaded to RAM by the debugger, and executed there.

Check your project settings.

shotkyy
shotkyyAuthor
Associate
November 26, 2019

Thank you!

waclawek.jan
Super User
November 26, 2019

Write your program so that it resides in FLASH, rather than RAM.

Read the manuals for your toolchain to understand how to locate code.

JW

PS. Please change your username to a nomal nick.

shotkyy
shotkyyAuthor
Associate
November 26, 2019

Thank you!

Tesla DeLorean
Guru
November 26, 2019

An information packed post...

What micro-controller?

What board? A custom one?

What tools are you using to program?

How have you checked the code is lost?

What is going on with your BOOT0 pin?

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
shotkyy
shotkyyAuthor
Associate
November 26, 2019

It's a STM32F446VE microcontroller used by the BlueCoin development kit.

I'am using IAR Workbench IDE and ST-LINK programmer/debugger (integrated on STM32nucleo board) ;

the firmware implements a dataLog with USB interface; after program loading (the firmware is correctly operating), i disconnect the board from my PC (board power off) and at the time of a subsequently connection of the board with usb cable to my pc, there is no program running on the mcu, and i don't see any VCP on my computer.

S.Ma
Principal
November 26, 2019

Check the power, the oscillator (if external). In your code, why not toggle a pin every 500msec to at least know the code is running?

shotkyy
shotkyyAuthor
Associate
December 1, 2019

Hi!

Why should I check the oscillator?

shotkyy
shotkyyAuthor
Associate
December 1, 2019

.

S.Ma
Principal
December 1, 2019

If you have an external crystal, you can check if it oscillate and the core is clocked. HSI is supposed to be the backup internal clock.

Most importantly, if your code works with STLink, does your MCU gets 3.3V from USB Device regulator properly?

Grab an oscilloscope and look at your signals and supplies.

If your code works with debugger it means it is in the flash already.