近日使用JTAG调试STM32F103C8T6时,无法使用JTAG连接目标板,却能够用SWD连接。由于时间紧,也没有细究其原因。闲下来以后,仔细研究了JTAG和SWD引脚的定义,排出了物理连接错误的可能。后来又怀疑是ST-link坏了,因为更换不同的目标板均不能连接。
仔细读了Keil的手册,发现如下:
Connect & Reset Options
control the instructions executed while connecting totarget.
Connect controls the connectionconditions.
- Connect — Normal stops the CPU atthe currently executed instruction after connecting.
- Connect — with Pre-reset appliesa hardware reset(HW RESET) before connecting to thedevice.
- Connect — under Reset holds thehardware reset(HW RESET) signal active while connecting to thedevice. Use this option when the user program disables the JTAG/SWinterface.
一开始我工程里Connnect选项设置的是Normal,更改为underReset后即变为正常,因此可以判断是芯片的JTAG被关闭了而SW依然使能,所以才会有上述现象。