[Record a STM32HAL library programming error]——Use ST-Link to download the stm32 program, do you need to press the reset button every time?

 question

 1. Before I encountered the problem of pressing the reset button every time I burned the stm32f103c8t6 program, I found the problem today: the code configured with cubemx disabled the swd port.

Maybe I forgot to configure it here . .

2. You can use the project of the standard library to download the program next time. If it can be downloaded normally, it is not a problem with the ST-Link and STM32 boards, it must be a problem with the program. . . .

Solution

Change it to Serial Wire and regenerate the project.

禁止SWD
 /** DISABLE: JTAG-DP Disabled and SW-DP Disabled 
  */
  __HAL_AFIO_REMAP_SWJ_DISABLE();

使用SWD
 /** NOJTAG: JTAG-DP Disabled and SW-DP Enabled 
  */
  __HAL_AFIO_REMAP_SWJ_NOJTAG();

summary

It is recommended that you master the two methods of writing programs in the standard library and the HAL library. .

Guess you like

Origin blog.csdn.net/weixin_62261692/article/details/130245237