XJTAG 3.11 introduces support for the ARM Serial Wire Debug (SWD) protocol in XJEase using our XJLink2-based JTAG controllers.
Reading and writing with the SWD protocol is made simple using two new XJEase functions SWD_READ and SWD_WRITE. They handle the transfer of data on the bidirectional data connection, keeping the code in XJEase clean and simple.
If you have a device that supports JTAG and SWD (SWJ-DP) we have added a new SWD … END; code block that will automatically switch the device between JTAG and SWD modes for you.
Raw data transfer functions have also been added for direct control of the SWD data pin, these are SWD_RAW_RECEIVE and SWD_RAW_SEND.
To get started with SWD, first define your SWD pins on the Pin Mapping Screen. You must have an XJLink2-based device connected:
Choose your SWD pins:
Once this is set up you can write a test using SWD for these pins; here is an example piece of code:
CONST INT DPIDR := 0x0; CONST INT CTRL := 0x4; CONST INT DP := 0x0; CONST INT AP := 0x1; INT id, data; SWD //places the device into SWD mode SWD_READ(DP, DPIDR[3..2])(id); //read the ID code PRINT("ID code: 0x", FORMAT(id, "%08X\n")); SWD_WRITE(DP, CTRL[3..2], 0x50000000); //request power up SWD_READ(DP, CTRL[3..2])(data); //read back PRINT("Data: 0x", FORMAT(data, "%08X\n")); END; //switches the device back to JTAG mode
Using the XJDemo v4 this will output:
ID code: 0x2BA01477 Data: 0xF0000000
More information on all these SWD functions can be found in the help files included with your installation. More information on the SWD protocol can be found at www.arm.com.