You copied the Doc URL to your clipboard.

How to switch the debugger connection between JTAG and SWD (Serial Wire Debug) protocol

Article ID: 103488051

Published date: 24 Jan 2018

Last updated: -

Applies to: Cortex-M3, Cortex-M4


How do I switch the debugger connection between JTAG and SWD (Serial Wire Debug) protocol?


The SWJ-DP component supports both protocols - Serial Wire and JTAG. The selector is part of the SWJ-DP.

The default protocol at power-up is JTAG, so you must use the TCK and TMS pins to scan in a special 'key' if you want to use Serial Wire. This key is a sequence of TMS values that has no effect for a pure JTAG TAP but is recognized by a SWJ-DP TAP as a request to switch into Serial Wire mode. Similarly, there is another TMS sequence to switch back from SWD to JTAG protocol.

The key sequences for switching to Serial Wire mode and back again are described in section 5.2 of the ARM Debug Interface Architecture Specification ADIv5.0 to ADIv5.2 (or 'ADIv5.2') which can be found n the Arm Developer web site, see the link in Related information.

The 16-bit JTAG-to-SWD select sequence is 0b0111 1001 1110 0111, most-significant-bit (MSB) first. This can be represented as one of the following:

  • 0x79E7, transmitted MSB first.

  • 0xE79E, transmitted least-significant-bit (LSB) first.

The 16-bit SWD-to-JTAG select sequence is 0b0011 1100 1110 0111, MSB first. This can be represented as either of the following:

  • 0x3CE7, transmitted MSB first

  • 0xE73C, transmitted LSB first.

More recent versions of SWJ-DP implement SWD Protocol version 2, which introduces a Dormant state as well as JTAG and SWD states. Dormant operation is described in section 5.3 of the ADIv5.2 document.

Differences between version 1 and version 2 of the SWD protocol are described in section 4.2.1 of the ADIv5.2 document.

Was this page helpful? Yes No