2024-07-18 11:20 PM - edited 2024-07-18 11:22 PM
I am new to embedded programming and very recently got started with programming the STM32F407G Disc-1 board with STM32CubeIDE(1.12.0).
I typical register level program for LED blinking:
Blinking the on-board LED - LD4.
int main(void)
{
uint32_t *clk_reg = (uint32_t*)0x40023830;
uint32_t *D_IO_Mode_reg= (uint32_t*)0x40020C00;
uint32_t *D_Out_data_reg= (uint32_t*) 0x40020C14;
*clk_reg= *clk_reg|0x08; //port D clock is Enabled
*D_IO_Mode_reg = *D_IO_Mode_reg & 0xFCFFFFFF;//clearing of 24 bit
*D_IO_Mode_reg = *D_IO_Mode_reg | 0x01000000;//set 24 bit
*D_Out_data_reg = *D_Out_data_reg|0X1000; //setting the 12th pin high
}
After I run the debug session and check the relevant registers, everything looks fine and the LED turns on, as it should be. However, when I terminate the debug session the LED is still ON!!.
I plugged out my device from the computer and put it back in, and still the LED is ON.
What is going on? Even the onboard reset pin doesn't reset the LED. What is wrong with my process? and how do I reset my board back to its default state??
Solved! Go to Solution.
2024-07-19 04:36 AM - edited 2024-07-19 04:37 AM
Hello @dip ,
You can erase the memory of your STM32F407G-DISC1 using some tools provided by ST.
CubeProgrammer, a tool provided by STMicroelectronics, allows you to manage this task efficiently.
Here is a step-by-step guide to erasing the memory of a microcontroller using CubeProgrammer:
Step 1: Installing CubeProgrammer
Step 2: Launching CubeProgramme
Step 3: Connecting to the Microcontroller
Step 4: Erasing the Memory
CubeIDE, an integrated development environment provided by STMicroelectronics, also allows you to erase the memory of a microcontroller.
You can go to the startup tab in the “debug configuration” and add "monitor flash mass_erase" as an Initialization command.
I hope my answer has helped you. When your question is answered, please select this topic as solution that answered you, it will help others find that answer faster.
Thanks for your contribution.
Dor_RH
2024-07-19 12:04 AM
>What is going on?
You flash/put a program to the cpu and then big surprise: its running ? With debug connected or not ...
>and how do I reset my board back to its default state??
No way to "go back" - only "go on" to next/new program.
Just flash a new program to the cpu, if this is the "original" demo program, then you have this behavior again.
+
Maybe read/learn a little bit about these magic things, like cpu's and programs...
https://wiki.st.com/stm32mcu/wiki/Category:STM32CubeIDE
2024-07-19 04:36 AM - edited 2024-07-19 04:37 AM
Hello @dip ,
You can erase the memory of your STM32F407G-DISC1 using some tools provided by ST.
CubeProgrammer, a tool provided by STMicroelectronics, allows you to manage this task efficiently.
Here is a step-by-step guide to erasing the memory of a microcontroller using CubeProgrammer:
Step 1: Installing CubeProgrammer
Step 2: Launching CubeProgramme
Step 3: Connecting to the Microcontroller
Step 4: Erasing the Memory
CubeIDE, an integrated development environment provided by STMicroelectronics, also allows you to erase the memory of a microcontroller.
You can go to the startup tab in the “debug configuration” and add "monitor flash mass_erase" as an Initialization command.
I hope my answer has helped you. When your question is answered, please select this topic as solution that answered you, it will help others find that answer faster.
Thanks for your contribution.
Dor_RH