Boundary Scan / JTAG
Setting up your first Boundary Scan/JTAG
Introduction
JTAG is the main standard for Boundary Scans. It works by having data flow through the boundary devices while reading the state of the pins to check that the connections on the PCB are working properly. The Boundary Scan Description Language (BSDL) files are required to determine if a single device is working as expected. For a Boundary Scan, the devices need to have dedicated registers.
To understand what a Boundary Scan is, visit the Microchip JTAG Boundary Scan page and associated links.
Hardware
- TSEG-JLINK - SEGGER J-Link Debug Probe
- DSPIC33CK Curiosity Development Board. Part Number: DM330030
- MPLAB® PICkit™ 5 In-Circuit Debugger
- Cables
Software
Many software packages for Boundary Scan are not free to use. See the attached zips, or use this Github link. Then go to releases and download the appropriate zip file. This should lead to the same zip files as attached.
- BSDL file (see Step 2)
- (attached)
- (attached)
- MPLAB X IDE
Software Setup
Download the attached .zip files or follow this GitHub link
There's no need for installation. Just download the appropriate file for your PC.
Get the SEGGER JLinkARM.dll file
Go to the SEGGER J-Link main page. Then download and install the last J-Link software.
Then go to the installation location, which you selected during the installation. By default, JLinkARM.dll file will be in C:\Program Files\SEGGER\JLink_V794b which is the same as the attached J-link file.
For Boundary Scans using the JTAG Boundary Scanner software, add the JLinkARM.dll file to the JTAGBoundryScanner program’s folder.
This tells the GUI what interface it should look for. In our case it is J-link. If the JTAG is different, download the appropriate .dll file from its website. It should be in the driver’s folder.
BSDL File
Microchip provides a BSDL file for most devices with dedicated hardware, a JTAG Boundary Scan Interface. (BSC, BSR, TAP controller).
Microchip Online Docs
The purpose of this BSDL file is to configure a Boundary Scan for just one MCU/device. If you want to add more MCUs in the same Boundary Scan, you can gather the BSDL files for each MCU. Ideally, you will get this file when designing the PCB because most PCB design tools include an automatic BSDL creation tool.
To get Microchip BSDL files, go to Microchip Online Docs and search. Note that the proper BSDL file may not be under the BSDL filter. In our case, for dsPIC33CK256MP508, see the BSDL file attached.
For Boundary Scan use the JTAG Boundary Scanner, the .bsdl file needs to be copied into the “bsdl_files” folder
Hardware Setup
Connect TDO, TDI, TCK, TMS, VTref, and GND pins. One GND pin is all that is needed. VTref is connected to Vdd=Vcc=3.3V. Below is a diagram showing each pin in the J-link and its function.
Below is a snapshot of the DSPIC33CK Curiosity Development Board datasheet indicating where to connect the JTAG pins.
If you have a different MCU, check the datasheet to determine where to connect these four pins. The following image is how the setup should look:
Firmware Setup
JTAGEN
The JTAGEN bit controls whether the pins are used as JTAG or standard I/O pins. In the dsPIC33CK256MP508, the MCU contained in our dsPIC33 board, the name of the register containing JTAGEN is FICD. This name may vary in other MCUs.
This register can be a configuration bit depending on the MCU. In our case, it is a configuration bit.
This register is set as 1 when the Flash memory is erased. This is done so a Boundary Scan can be done without programming the chip. But the value of JTAGEN is 0 when the MCU is programmed with an MPLAB X IDE code that doesn’t specify it.
Verify that this bit is set as 1 whenever a Boundary Scan occurs. Connect the board through a USB or a PICkit (adding headers) to the computer.
If JTAGEN is not a configuration bit: Create a simple program adding a line to set JTAGEN. For example, for the PIC32MX340F128H:
DDPCONbits.JTAGEN=1
If JTAGEN is a configuration bit: you can create a program modifying the configuration bits:
Or you can use MPLAB X IPE to modify it:
JTAGBoundaryScanner
Click on Probe and then the displayed option
Click again on JTAG Chain and the new Device now appears. Now select the proper BSDL file, previously downloaded.
You may get an error for two different reasons:
- The device BSDL file doesn’t match with the one being used. Make sure you are using the proper BSDL.
- The revision of the device is different than the BSDL revision.
This shouldn’t make the Boundary Scan fail. You can click Yes and continue without worrying. Avoid the notification by opening the BSDL file and modifying its ID to match the Device ID.
Now you should see something similar to this:
To understand the columns O, OE, I and T, and the two Boundary Scan modes, click on Help > Help.
To start the Boundary Scan, click Scan mode and select a refresh rate and the Boundary Scan mode.
Now you can start doing Boundary Scans. If using the DSPIC33CK Curiosity Development Board, try ticking the “OE” and “O” boxes of RE13, RE14, and RE15 pins. This should make the LED change its color, according to its datasheet.