JTAG 和 SWD 接口定义

本文介绍了JTAG和SWD两种接口在调试硬件时的引脚分布和功能,包括参考电压、未连接引脚、时钟信号、数据传输和复位信号。JTAG包含TCK、TDI、TMS、TDO和可选的nTRST,而SWD则主要使用SWDIO、SWCLK和可选的SWO。两者都涉及目标CPU的复位和时钟信号管理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

写在前面:

本文章旨在总结备份、方便以后查询,由于是个人总结,如有不对,欢迎指正;另外,内容大部分来自网络、书籍、和各类手册,如若侵权请告知,马上删帖致歉。


链接:https://arachnid.cc/jtag-and-swd


JTAG

https://wiki.segger.com/JTAG

引脚分布

在这里插入图片描述

接口定义

PINSIGNALTYPEDescription
1VTrefInputThis is the target reference voltage. It is used to check if the target has power, to create the logic-level reference for the input comparators and to control the output logic levels to the target. It is normally fed from VDD of the target board and must not have a series resistor.
2Not connectedNCThis pin is not connected.
3nTRSTOutputJTAG Reset. Output from J-Link to the Reset signal of the target JTAG port. Typically connected to nTRST of the target CPU. This pin is normally pulled HIGH on the target to avoid unintentional resets when there is no connection.
5TDIOutputJTAG data input of target CPU. It is recommended that this pin is pulled to a defined state on the target board. Typically connected to TDI of the target CPU.
7TMSOutputJTAG mode set input of target CPU. This pin should be pulled up on the target. Typically connected to TMS of the target CPU.
9TCKOutputJTAG clock signal to target CPU. It is recommended that this pin is pulled to a defined state of the target board. Typically connected to TCK of the target CPU.
11RTCKInputReturn test clock signal from the target. Some targets must synchronize the JTAG inputs to internal clocks. To assist in meeting this requirement, you can use a returned, and adjusted, TCK to dynamically control the TCK rate. J-Link supports adaptive clocking, which waits for TCK changes to be echoed correctly before making further changes. Connect to RTCK if available, otherwise to GND.
13TDOInputJTAG data output from target CPU. Typically connected to TDO of the target CPU.
15nRESETI/OTarget CPU reset signal. Typically connected to the RESET pin of the target CPU, which is typically called “nRST”, “nRESET” or “RESET”. This signal is an active low signal.
17DBGRQNCThis pin is not connected in J-Link. It is reserved for compatibility with other equipment to be used as a debug request signal to the target system. Typically connected to DBGRQ if available, otherwise left open.
195V-SupplyOutputThis pin can be used to supply power to the target hardware. Older J-Links may not be able to supply power on this pin. For more information about how to enable/disable the power supply, please refer to Target power supply.
4, 6, 8, 10, 12GNDGroundGND pins connected to GND in J-Link. They should also be connected to GND in the target system.
14, 16, 18, 20ResReservedOn some models like the J-Link ULTRA, these pins are reserved for firmware extension purposes. They can be left open or connected to GND in normal debug environment. They are not essential for JTAG or SWD in general Please do not assume them to be connected to GND inside J-Link.

连接拓扑

在这里插入图片描述

引脚概述

序号引脚类型说明
9TCK输出目标时钟输入引脚,为目标 CPU 提供时钟逻辑信号。
5TDI输出目标数据输入引脚,用于发送串行测试指令和数据给目标 CPU。
7TMS输出目标模式选择引脚,TAP(Test access port) 控制器对接收到的信号进行解码,以控制测试操作。
13TDO输入目标数据输出引脚,目标 CPU 串行输出测试指令和逻辑数据。
3nTRST输出(可选)可选的复位输入目标引脚,用来指示 TAP 控制器的异步初始化。
11RTCK输入目标 CPU 返回的时钟信号,有些目标 CPU 需要同步时钟。
15nRESET输入 / 输出目标 CPU 复位信号。通常连接到目标 CPU 的 RESET 引脚。

SWD

https://wiki.segger.com/SWD

引脚分布

在这里插入图片描述

接口定义

PINSIGNALTYPEDescription
1VTrefInputThis is the target reference voltage. It is used to check if the target has power, to create the logic-level reference for the input comparators and to control the output logic levels to the target. It is normally fed from VDD of the target board and must not have a series resistor.
2Not connectedNCThis pin is not connected.
3Not usedNCThis pin is not used by J-Link when selecting SWD as interface type. If the device may also be accessed via JTAG, this pin may be connected to nTRST, otherwise leave open.
5Not usedNCThis pin is not used by J-Link when selecting SWD as interface type. If the device may also be accessed via JTAG, this pin may be connected to TDI, otherwise leave open.
7SWDIOOutputJTAG mode set input of target CPU. This pin should be pulled up on the target. Typically connected to TMS of the target CPU.
9SWCLKOutputJTAG clock signal to target CPU. It is recommended that this pin is pulled to a defined state of the target board. Typically connected to TCK of the target CPU.
11Not usedNCThis pin is not used by J-Link when selecting SWD as interface type. If the device may also be accessed via JTAG, this pin may be connected to RTCK, otherwise leave open.
13SWOInputSerial Wire Output trace port. (Optional, not required for SWD communication.)
15nRESETI/OTarget CPU reset signal. Typically connected to the RESET pin of the target CPU, which is typically called “nRST”, “nRESET” or “RESET”. This signal is an active low signal.
17Not usedNCThis pin is not connected in J-Link.
195V-SupplyOutputThis pin can be used to supply power to the target hardware. Older J-Links may not be able to supply power on this pin. For more information about how to enable/disable the power supply, please refer to Target power supply.
4, 6, 8, 10, 12GNDGroundGND pins connected to GND in J-Link. They should also be connected to GND in the target system.
14, 16, 18, 20ResReservedOn some models like the J-Link ULTRA, these pins are reserved for firmware extension purposes. They can be left open or connected to GND in normal debug environment. They are not essential for JTAG or SWD in general Please do not assume them to be connected to GND inside J-Link.

连接拓扑

在这里插入图片描述

引脚概述

序号引脚类型说明
9SWCLK输出时钟信号引脚。
7SWDIO输入 / 输出双向数据引脚。
13SWO输出(可选)可选的串行线跟踪输出引脚,允许 CPU 输出自定义数据,如 printf 输出,异步到 SWCLK 和其他调试引脚。
15RESET输入 / 输出目标 CPU 复位信号。通常连接到目标 CPU 的 RESET 引脚。

参考

https://wiki.segger.com/20-pin_J-Link_Connector

https://developer.arm.com/documentation/101636/0100/Debug-and-Trace/JTAG-SWD-Interface

在这里插入图片描述

电路

在这里插入图片描述

如果是要兼容 SWD,则需要在 JTAG_TMS 引脚的上拉电阻前端增加一个二极管,参照 JTAG_nRESET 上拉。

附录

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值