AN6274 · Application noteGetting started with STM32C5 MCU hardware development
Download .pdfOpen in the full document

Debug management

SWJ-DP (serial-wire and JTAG debug port)

The core of the STM32C5 microcontrollers integrates the serial wire / JTAG debug port (SWJ-DP). It is an Arm® standard CoreSight™ debug port that combines a 5-pin JTAG-DP interface and a 2-pin SW-DP interface.
  • The JTAG debug port (JTAG-DP) provides a 5-pin standard JTAG interface to the AHP-AP port.
  • The serial wire debug port (SW-DP) provides a 2-pin (clock + data) interface to the AHP-AP port.
In the SWJ-DP, the two JTAG pins of the SW-DP are multiplexed with some of the five JTAG pins of the JTAG-DP.
Note:

All SWJ port IOs can be reconfigured to other functions by software, but debugging is no longer possible. All SWJ port IOs can be reconfigured to other functions by software, but debugging is no longer possible.

For more details on the SWJ debug port, refer to the reference manual of the product.

The NRST pin is needed to run debug authentication.

SWJ-DP pins

Five pins are used as outputs for the SWJ-DP, as alternate functions of the GPIOs (general-purpose I/Os). These pins are available on all packages and detailed in the table below.

Table 5. JTAG/Serial-wire debug port pins
Pin nameJTAG debug portSerial-wire debug portPin assignment
TypeDescriptionTypeDescription
JTMS/SWDIOInputJTAG test mode selectInput/OutputSerial-wire data in/outPA13
JTCK/SWCLKInputJTAG test clockInputSerial-wire clockPA14
JTDI (1)InputJTAG test data input--PA15
JTDOOutputJTAG test data output--PB3
nJTRSTInputJTAG test reset--PB4
1 TDI is hosted on the same IO as a USBPD-CC line. To avoid pull-up/down conflict, a user option can help to decide whether the pad is used as TDI or as CC.

Flexible SWJ-DP pin assignment

After reset (SYSRESETn or PORESETn), all five pins used for the SWJ-DP are assigned as dedicated pins that are immediately usable by the debugger host.
Note:

The trace outputs are not assigned except if explicitly programmed by the debugger host.

The table below shows the different possibilities for releasing some pins.

Table 6. SWJ-DP I/O pin availability
Available debug portsSWJ-DP I/O pin assigned
PA13 /JTMS/SWDIOPA14 /JTCK/SWCLKPA15 /JTDIPB3 /JTDOPB4/nJTRST

Full SWJ‑DP (JTAG‑DP + SW‑DP) Reset state

xxxxx
Full SWJ‑DP (JTAG‑DP + SW‑DP) but without JNTRSTxxxx-
JTAG-DP disabled and SW-DP enabledxx-
JTAG-DP disabled and SW-DP disabledReleased

Internal pull-up and pull-down resistors on JTAG pins

The JTAG input pins must not be floating since they are directly connected to flip-flops that control the debug mode features. Special care must be taken with the SWCLK/TCK pin that is directly connected to the clock of some of these flip-flops.

To avoid any uncontrolled I/O levels, the devices embed the following internal resistors on the JTAG input pins:
  • JNTRST: internal pull-up
  • JTDI: internal pull-up
  • JTMS/SWDIO: internal pull-up
  • TCK/SWCLK: internal pull-down
Once a JTAG I/O is released by the user software, the GPIO controller takes the control again, and the software can then use these I/Os as standard GPIOs. The reset states of the GPIO control registers put the I/Os in the following equivalent states:
  • JNTRST: input pull-up
  • JTDI: input pull-up
  • JTMS/SWDIO: input pull-up
  • JTCK/SWCLK: input pull-down
  • JTDO: input floating
Note:

The JTAG IEEE standard recommends adding pull-up resistors on TDI, TMS, and nTRST, but there is no special recommendation for TCK. However, for the devices, an integrated pull-down resistor is used for JTCK. Having embedded pull-up and pull-down resistors removes the need to add external resistors.

SWJ-DP connection with standard JTAG connector

The figure below shows the connection between the device and a standard JTAG connector.
Figure 6. JTAG connector implementation