The STM32 chip was fine just now, why suddenly it can't be programmed? try this

Burning problem

Use punctual atomic routines and download them to your own board. Since the atomic routines are configured with an 8M high-speed external clock, and my motherboard has a 25M crystal oscillator, it was a tragedy. The program cannot be programmed into the chip. Every time I try to download the program, an error dialog box pops up. It is unlikely that the J-Link and STM32 chips will just break. So I searched for a solution on the Internet, and after breaking a chip, I finally found a solution. I shared it for the reference of novices, and the master passed by.
 

Situation one:

After downloading someone else's routine, the external high-speed clock configuration is different from the actual motherboard's crystal oscillator, and then the chip cannot be connected and programmed. This is the case for me.

Situation two:

For example, if the following code is programmed in, it will cause J-Link to be unable to connect normally next time:

GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable,ENABLE);

The above code indicates to cancel the JTAG pin function and start the SWD pin function.

Solution:

STM32 comes with BootLoader, just switch to BootLoader. The specific method is to select the startup mode through the two jumpers BOOT1 and BOOT0. Modify the jumper to switch the boot mode to the second method above: BOOT0=1, BOOT1=0.

Power off, change the jumpers, power on again, and enter the second mode: BOOT0=1, BOOT1=0, which is the BootLoader mode of STM32. At this time, J-Link can work normally. Use J-Link to download new programs and the download is successful. Power off again, change the jumpers back to the first boot mode (BOOT0=0, BOOT1=0), power on again, everything is normal, and the problem is solved.

Appendix 1: Understanding BOOT0 and BOOT1

There are two pins BOOT0 and BOOT1 on each STM32 chip. The level status of these two pins when the chip is reset determines which area the chip starts to execute the program from after it is reset. See the table below:

BOOT1=x BOOT0=0 Boot from user flash memory, this is the normal operating mode.

BOOT1=0 BOOT0=1 starts from the system memory. The program functions started in this mode are set by the manufacturer.

BOOT1=1 BOOT0=1 Boot from built-in SRAM, this mode can be used for debugging.

It should be noted that the built-in SRAM is generally not used for booting (BOOT1=1 BOOT0=1), because the data will be lost when the SRAM is powered off. In most cases, SRAM is only used for debugging, but can also be used for other purposes. For local diagnosis of faults, write a small program and load it into SRAM to diagnose other circuits on the board, or use this method to read and write Flash or EEPROM on the board, etc. You can also use this method to remove the read and write protection of the internal Flash. Of course, when the read and write protection is released, the content of the Flash will also be automatically cleared to prevent malicious software copying.

Generally, the BOOT0 and BOOT1 jumpers jump to 0 (GND). Only in the case of ISP downloading, BOOT0=1, BOOT1=0. After the download is completed, connect the BOOT0 jumper back to 0, that is, BOOT0=0, BOOT1=0.

For general applications, just connect the BOOT0 and BOOT1 pins directly to ground without setting jumpers. When using the IAR debugger, you can choose RAM debugging or Flash debugging, regardless of the configuration of BOOT0 and BOOT1.

Appendix 2: Practical identification method of integrated chip pin 1:


Method 1: When there is a smallest dot, the corresponding foot is one, and the order is rotated counterclockwise.

Method 2: When there is a small semicircular notch on the chip, when the notch is facing left, there is a foot on the lower left, and the order is arranged by turning counterclockwise.

Method 3: When there are no small dots and small gaps, the way to determine the pin is that when the number and model on the chip are facing us, then the first leftmost pin under the chip is the first pin, and finally Just count the feet counterclockwise.

Guess you like

Origin blog.csdn.net/llq_the7/article/details/108523675