SWD block
SWD blocks are used to automatically generate signals to perform the Switching Mechanism Select Sequence to place target components into SWD mode. Exiting the outermost SWD block generates the signals to switch the target back to to JTAG mode. The sequences generated are defined by the Arm Debug Interface SWD Protocol specification and XJTAG's implementations are defined at the bottom of this page.
Syntax
SWD ... END;
When SWD pins are on JTAG TAP pins
The following JTAG-related functions are not allowed inside the SWD block:
- SET statements (but PIO SET statements are allowed)
- Raw JTAG blocks
- JTAGWAIT
- SAFE
- CONNTEST
- RUNSTAPL
- RUNSVF
After exiting the outermost SWD block the JTAG chain is considered to be unconfigured. The next JTAG operation will therefore first cause the reset sequence to be run as if it was the first JTAG access of the test run.
When SWD pins are not on JTAG TAP pins
There are no restrictions on the use of JTAG functions within the SWD block.
In this situation the JTAG chain isn't considered to be unconfigured by the action of exiting the outermost SWD block. This means no additional reset sequence will need to be performed next time JTAG is used.
Although the SWD and JTAG chains are separate and can run at the same time, there is some configuration overhead within the hardware switching between JTAG and SWD operations so mixing JTAG and SWD operations should be kept to a minimum when overall test speed is a concern.
Other notes
SWD blocks may be nested within a function or across many functions through function calls, but the 'Switching Mechanism' to switch the device to SWD operation will only be called on entry to the first block, and switching the device back to JTAG will only occur after exit from the final block.
The first entry to an SWD block may not be done inside a HOLDOFF. However HOLDOFF
blocks are allowed inside SWD blocks, so if you want to use HOLDOFF
with SWD blocks, define the SWD block first.
Internal 'Switching Mechanism' information
The sequence used to switch a device from JTAG to SWD operation is:
- 55 1's
- 0xE79E, LSB first
- 55 1's
- 10 0's
The sequence used to switch a device from SWD to JTAG operation is:
- 55 1's
- 0xE73C, LSB first
- 10 1's
Examples
When SWD pins are on JTAG TAP pins:
INT address, idcode; SET address := ADDRESS; // By default the device is in JTAG operation, here a JTAG write is performed. SWD // Device switches to SWD operation. SWD_READ(0, 0)(idcode); // SWD function to read the ID code. END; // Device switches back to JTAG operation here. SET address := ADDRESS; // A reset sequence and then the JTAG write is performed.
When SWD pins are not on JTAG TAP pins:
INT address, idcode; SWD // SWD device switches to SWD operation, JTAG devices unaffected. SWD_READ(0, 0)(idcode); // SWD function to read the ID code. SET address := ADDRESS; // JTAG operations continue to work on the JTAG devices. SWD_READ(0, 0)(idcode); // SWD functions continue to work on the SWD device. END;
See also
- SWD protocol
- More details of how to use the Arm Debug Interface SWD Protocol are available from Arm
XJTAG v4.1.100