Over the years I have used a number of different approaches for the in-circuit programming (ICP) of the microcontrollers in the projects I have designed. None have been perfect, but I wanted to discuss the relative pros and cons of the various solutions.
The ICP connector will be used more or less continually while the project is in the prototype state, but (hopefully) only once in the production stage. The connection needs to be robust and reliable, have a small footprint and ideally be very cheap. Typically, we need four or five pins for protocols such as Arm Cortex Single-Wire Debug (SWD) or Microchip’s In-Circuit Serial Programming (ICSP). If we want to use full JTAG, or an advanced instruction trace we typically need up to 10 pins.
The most obvious solution is a 2.54mm header that is compatible with your favourite programmer/debugger. For example, I use a Segger J-Link (Figure 1) or ST-Link V2 (Figure 2) for Arm Cortex development and these have a 20-pin double-row header. You could put a similar connector on your project and just use a 20-way IDC ribbon cable. This is low(ish) in cost but takes up a large amount of precious PCB real estate, especially if you only need 5 pins for SWD. The connector measures about 31mm x 9mm and so takes up 279mm2 of PCB real estate.
One alternative is to use a 5-way single-row 2.54mm unshrouded header and make up a suitable cable. This works fine, is low in cost and reasonably robust. It measures about 16mm by 3mm and so has a footprint of 48mm2. It is not keyed, so it’s possible to insert it backwards or “off by one”. The 2.54mm header solutions are all relatively tall – about 16mm including the IDC connector.
Another popular solution is the “Plug-of-Nails” from Tag Connect. The plug consists of six or ten pogo pins which contact small pads on the target PCB (Figure 3). One version has plastic “claws” which clip into non-plated holes to hold the connector in place. Cables are available ready-made for a multitude of programmers. The board footprint is small (about 10mm x 7mm or 70mm2 for a 10-pin version).
The downside for the Tag Connect solutions is the price of the cables. These are not cheap especially if you use a few different debuggers and, like me, always want to have a spare on hand. Obviously the per board cost is zero since there is no target connector – great for production. I also find the height of this connector to be a problem in some circumstances.
Most recently I have been using an off the shelf 10-pin double-row 1.27mm connectors for my projects (Figure 4). These have the advantage of being small (6.3mm x 5.8mm or about 36mm2), low profile at 5mm in height, relatively cheap and available from a number of sources. They are keyed, so it’s impossible to connect wrongly. I am not the only one to use this connector for programming, so it has de-facto standard pin-out and an adaptor board is available from Adafruit to connect it to the J-Link. I use pre-terminated IDC cables and a small home-made adaptor board for my J-Link (Figure 5).
“J-Link Debug Probes.” Accessed June 15, 2021. https://www.segger.com/products/debug-probes/j-link/.
“ST-LINK/V2 – ST-LINK/V2 in-Circuit Debugger/Programmer for STM8 and STM32 – STMicroelectronics.” Accessed June 15, 2021. https://www.st.com/en/development-tools/st-link-v2.html.
Tag-Connect. “Tag-Connect.” Accessed June 15, 2021. https://www.tag-connect.com/.
Industries, Adafruit. “Mini SWD 0.05″ Pitch Connector – 10 Pin SMT Box Header.” Accessed June 15, 2021. https://www.adafruit.com/product/4048.
Industries, Adafruit. “JTAG (2×10 2.54mm) to SWD (2×5 1.27mm) Cable Adapter Board.” Accessed June 15, 2021. https://www.adafruit.com/product/2094Sponsor this Article
Andrew Levido (firstname.lastname@example.org) earned a bachelor’s degree in Electrical Engineering in Sydney, Australia, in 1986. He worked for several years in R&D for power electronics and telecommunication companies before moving into management roles. Andrew has maintained a hands-on interest in electronics, particularly embedded systems, power electronics, and control theory in his free time. Over the years he has written a number of articles for various electronics publications and occasionally provides consulting services as time allows.