cancel
Showing results for 
Search instead for 
Did you mean: 

LED keeps on blinking after I terminate the debug session.

dip
Associate

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??

 

1 ACCEPTED SOLUTION

Accepted Solutions
Dor_RH
ST Employee

Hello @dip , 

You can erase the memory of your STM32F407G-DISC1 using some tools provided by ST.

  • Erasing Memory Using CubeProgrammer

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

  1. Choose the erase option: Select the "Full chip erase" option to erase the entire memory of the microcontroller.
  2. Start the erasure: Click the "OK" button to begin the erasure process.

Dor_RH_1-1721388741217.png

  • Erasing Memory Using CubeIDE

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.

Dor_RH_2-1721388763941.png

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

View solution in original post

2 REPLIES 2
AScha.3
Chief III

>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://www.st.com/resource/en/user_manual/um2052-getting-started-with-stm32-mcu-discovery-kits-software-development-tools-stmicroelectronics.pdf

https://www.st.com/resource/en/user_manual/um1467-getting-started-with-software-and-firmware-environments-for-the-stm32f4discovery-kit-stmicroelectronics.pdf

 

https://wiki.st.com/stm32mcu/wiki/Category:STM32CubeIDE

 

If you feel a post has answered your question, please click "Accept as Solution".
Dor_RH
ST Employee

Hello @dip , 

You can erase the memory of your STM32F407G-DISC1 using some tools provided by ST.

  • Erasing Memory Using CubeProgrammer

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

  1. Choose the erase option: Select the "Full chip erase" option to erase the entire memory of the microcontroller.
  2. Start the erasure: Click the "OK" button to begin the erasure process.

Dor_RH_1-1721388741217.png

  • Erasing Memory Using CubeIDE

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.

Dor_RH_2-1721388763941.png

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