MCU烧录失败,有一种情况是JTAG/SW接口被禁用导致的。
通常是由于程序编写过程中关闭了JTAG/SW接口,或者JTAG/SW接口的引脚被有意无意地复用为其它功能了。这时候想要解决这个问题,核心就是让MCU上电启动的时候不要运行主Flash里面的程序,这样MCU的JTAG/SW接口就不会被干扰到,从而实现正常烧录。
方法一:
把BOOT0短接3.3V,再烧写就可以工作了,之后再用SWD烧录,无需再短接3.3V和BOOT0。
方法二:
Keil下设置 :Options → Debug → Use → Settings → Debug → Connect & Reset Options → Connect → under Reset 。
其它IDE下可以在设置里面找到相应的设置,实现同样的效果。
具体解释可以查看下面的链接:ULINK2 User's Guide: Debug
Connect & Reset Options
control the instructions executed while connecting to target.
Connect
- controls the operations that are executed when the µVision debugger connects to the target device. The drop-down has the following options:
▪ Normal just stops the CPU at the currently executed instruction after connecting.
▪ with Pre-reset applies a hardware reset(HW RESET) before connecting to the device.
▪ under Reset holds the hardware reset(HW RESET) signal active while connecting to the device. Use this option when the user program disables the JTAG/SW interface by mistake.
▪ without Stop connects to and disconnects from the target device without explicitly stopping the CPU. Use this option, for example, to inspect memory or peripheral SFRs.
原文链接:https://blog.csdn.net/elikang/article/details/122726736
|