# JTAG

https://wiki.segger.com/JTAG

# 引脚分布

img

# 接口定义

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.

# 连接拓扑

image-20230709160640502

# 引脚概述

序号引脚类型说明
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

# 引脚分布

img

# 接口定义

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.
7SWDIOI/OJTAG 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.

# 连接拓扑

image-20230709161124811

# 引脚概述

序号引脚类型说明
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

st-link接口定义:stm32f103c8t6 sw接口定义:上图序号swdpcb板上的

# 电路

image-20230709180456489

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

关于 J-Link 输出供电问题:

  • 一次性编程器打开或者关闭 5V-Supply 电源输出指令:
    POWER ON :一次性使能编程器电源输出。
    POWER OFF :一次性关闭编程器电源输出。
  • 长期记录编程器打开或者关闭 5V-Supply 电源输出指令:
    POWER ON PERM :长期打开编程器电源输出。
    POWER OFF PERM :长期关闭编程器电源输出。

# 附录

stm32jtag电路设计

更新于 阅读次数

请我喝[茶]~( ̄▽ ̄)~*

夏沫の浅雨 微信支付

微信支付

夏沫の浅雨 支付宝

支付宝