# Microcontroller's JTAG interface and PCB

I'm about to start making my own microcontroller circuit (using an Atmega series MCU, at least for the beginning) and I think I'm gonna get the AVR JTAGICE JTAG debugger & programmer. I also plan on making my own PCB lab at home so I was wondering - based on your experience - if it was better to use DIP packages or SMD (SOIC, TSSOP, TQFP/LQFP).

As far as I understood DIP packages are preferred in the D.I.Y. sector, whereas SMD are better because they take less space and should be less sensible to electromagnetic interference (for instance with other ICs).

Now to the question: if you need to (re-)program the microcontroller, which one would you use ? AFAIK there are two alternatives:

1. Use a DIP socket soldered to the PCB and put the DIP MCU in there. Whenever I need to reprogram it, I take it out of the socket, put into an adapter-like board to JTAG, reprogram it and transfer it back to the socket
2. Put a SMD component on the PCB and let a JTAG port accessible from the exterior (should be 20 pins, right ?). I'd also like to keep the circuit as small as possible, so are there any low-footprint headers with 20 pins ? Sorry but I don't know how they're called exactly. It doesn't need to be JTAG really: I can leave a low-footprint header there, go onto an adapter PCB with a cable and go to the debugger via the official JTAG cable.

I think the first solution is the simplest and probably a bit cheaper. It should even be easier to solder. What do you suggest ?

• You don't want to move your DIP microcontroller from one socket to another very often, just to program it. After a while, you could bend or even break the pins of the uC.. – m.Alin Jun 22 '12 at 7:13

There are sockets available for both DIP packages and SMD packages. No matter which direction you take, I would suggest using a socket. That way, if you let the smoke out, replacing the chip doesn't require desoldering and resoldering.

The choice between DIP and SMD is all about what you are more comfortable with. There is typically a larger variety of microcontrollers available in SMD. But they are also more fragile. Especially when used with a socket. If you're taking the chip in and out a lot, you will most likely bend or break some pins. The pins on a DIP are much more forgiving in this respect.

It's rare that you'll find someone taking a chip out of circuit and placing it in an off-board programmer these days. I had to do it with old school PROMs in college. But I haven't done it since. You are much better off having the JTAG on the board itself. @i.amniels mentioned in-circuit debugging being a huge advantage. I will echo that sentiment as it cannot be said enough.

There are many different JTAG connector configurations. The AVR one uses 10 pins. And you really don't have a lot of say in the footprint of the header you can choose. You have to match the pin size and pitch to your JTAGICE. Atmel has a recommendation for the part number to use to interface to the JTAGICE. I would just stick with that.

http://support.atmel.com/bin/customer.exe?=&action=viewKbEntry&id=2

• The part number suggested on Atmel's site is now obsolete (Digikey & Mouser). What do you mean there are sockets for SMD packages? If I recall there are, but they cost like 50$each. – user51166 Jun 22 '12 at 5:06 • Sorry I didn't check the availability. The nice thing about DigiKey is they link to the replacement when something goes obsolete: digikey.com/product-detail/en/10-89-7102/WM26810-ND/851737. Or here is another choice: digikey.com/product-detail/en/5103308-1/A33159-ND/1114897. – embedded.kyle Jun 22 '12 at 12:50 • You didn't say which Atmega you were using (unless I overlooked it) so I can't provide a specific example. But yes, SMD sockets cost between$50-$100 or more. But if you run into a problem and are changing chips often, you are going to lift traces. So you have to weigh that one time$50 cost versus the time and cost to get a whole new PCB. The socket will save you money and frustration in the long run. – embedded.kyle Jun 22 '12 at 12:52
• I was speaking of the "standard" Atmega series that cost less than 3$a piece (not sure which one exactly yet). I think that in this case the socket is overexpensive (> 15 times the cost of the MCU). With ARM processors costing > 10$ the socket would be definitively an option (expecially for a prototype). – user51166 Jun 22 '12 at 13:27
• If I understand you correctly you will be etching your own boards as home. Say the ATmega blows and you lift a trace desoldering it. $3 for the Atmega,$10-$15 for the PCB + supplies to etch it, your time to etch it, your time to desolder and resolder all of the other components to the new board. If you trash your board twice, the socket would have paid for itself. I can't tell you how many$5000 boards I've trashed when a \$1000 socket would have saved them. But my boss wouldn't bite on the upfront cost. Yes, it's expensive. But think long term. You'll thank me later. – embedded.kyle Jun 22 '12 at 13:41

When you add a JTAG port to your PCB, you can use the JTAG to debug your software while the microcontroller is on your PCB. This is a huge advantage and will speed up debugging.

The choise between between DIP and SMD depends on your soldering skills. If you are able to solder SMD, choose SMD. It's smaller and there are more different microcontrollers available with a SMD package.

• Yeah but I mean: is there a small footprint 20 pin header (not the standard 2.54mm pitch) that I can solder on the board as a JTAG access interface ? I'd like to avoid using the 2.54mm pitch headers because they take much place for nothing in this case. – user51166 Jun 21 '12 at 20:21
• @user51166 You may want something like this. – m.Alin Jun 22 '12 at 7:04
• Ok thank you. I suppose there exists even those with the "plastic frame" so that the JTAG cable could only connected the right way. – user51166 Jun 22 '12 at 11:41

The first solution is clumsy. You'll get tired of taking out the chip, programming it and then putting it back.

The best solution is to use in-circuit programming, weather or not you use DIP is irrelevant. For AVRs, you can use JTAG or ISP. Atmel's implementation of JTAG requires only 10 pins, not 20. The advantage over ISP is that you can debug your circuit.

If you have a lot of space on your PCB, you can just utilize a 2x5 0.1" header and be done with it. I normally use a polarized connector to ensure I don't plug in the programmer backwards.

If you are tight on space, you can bring out some pads and use pogo-pins to connect the AVR to your programmer/debugger. See this answer for more information regarding pogo-pins.

• Thank you. I read the answer but can't really figure out what avantage they may offer. Seeing the item on adafruit.com (as said in the article) it seems to me that this solution is used to build multi-level board (very useful for lots of components, where we can develop in height). For a tight fit it seems to me it's not so good. Do you mind clarifying, please ? – user51166 Jun 22 '12 at 5:23
• @user51166 To program my microcontroller I have a 2x5 0.1" header - much like this. Relative to your uC's size, this connector is quite large. If you have very limited space on your PCB, you can utilize pogopins instead of the header. The pogopins have every small footprint so you'll save quite a bit of space. – Saad Jun 22 '12 at 5:34
• OK. From the images I saw they looked far bigger than a header pin, but I'll give them a try. Thank you. – user51166 Jun 22 '12 at 13:30

If you want to get reasonably serious about electronics you will have to tackle SMD at some stage anyway, so if possible I'd take this route. You will have far more choice since many ICs don't have a through hole version anymore. I would say hobbyists are using SMD a lot more nowadays, so I'm not sure if it's "preferred" still.

Either way as mentioned, program it on the PCB. As far as the header is concerned it's unlikely all 10 or 20-pins will be needed signal wise, so you can probably get it down to around 5 pins if you check the pinout and datasheets.
Sometimes manufacturers sell different adapters for their programmers so have a look to see - for example Microchip sell a handy pogo pin adapter for the ICD3, so you only need to hold it against a few pads on the board during programming.
If there isn't something available, make it. I recently did this with an ARM uC from ST - my Ride programmer comes with a ~20-pin header so we made a little adapter for it to fit onto a 5-pin header to save space.

• That was the idea I had in mind, but are you still using 2.54mm pitch on the PCB or you shrink it down to save even much space? Did you place your headers one by one or there is some 5-pin header all in one, even better with plastic around it so that cables can only put one way ? Thank you. – user51166 Jun 22 '12 at 5:10