# Pre-programming surface mount ICs

I'm trying to set up a PCB with an atmega168 and no programming header. I intend to use a serial bootloader (there is a ft232 on the board) to reprogram but I am wondering about the best way to program the bootloader on. Has anyone else tried this before? I am having trouble sourcing a tqfp-32 zif socket.

• Are you doing this just one time? – Dirk May 28 '10 at 13:26
• I will be doing it for a whole batch (>1) – jeremy May 28 '10 at 21:58
• – davidcary Sep 24 '11 at 18:00

It might be easier to bring out the programming pins to some pads then use pogopins to attach your programmer.

• If the board is dense you could also turn existing vias into programming points. You need to remove the soldermask and possibly change the pad and hole size. A row of pads could be a lot easier if it fits. – jluciani May 28 '10 at 17:07
• what the heck are pogopins... are you talking about a 2x3 ISP header (see my answer below) – vicatcu May 28 '10 at 18:11
• Pogo pins are metal rods with spring-loaded tips. They're often used in test fixtures when you need to make a temporary connection to a circuit. – pingswept May 28 '10 at 18:16
• Picture of pogo pins: flickr.com/photos/pingswept/2280832792 – pingswept May 28 '10 at 18:17
• adafruit.com/blog/2010/06/10/how-to-make-a-pogo-pin-testing-jig – endolith Oct 27 '10 at 15:33

If you are buying these in large volumes often you can buy chips directly from the vendor pre-programmed with your boot loader. I'm not sure if Atmel offers this service, but I know Microchip does so I would assume they do as well.

Just put an ISP header on your board as an "alternative" to the serial bootloader. Then use something like the AVRISP MkII to program your hex file and fuses with AVRStudio. Maybe you only use it once to load the bootloader, but it's by far the most cost-effective solution you're going to find.

In case you don't know what I mean by an ISP header, it's a 2x3 male header, with the following pinout:

2x3 pin    connect to AVR pin
1          MISO
2          VCC
3          SCK
4          MOSI
5          RESET
6          GND


Odd numbered pins are on one row, even numbered pins are on the other row, and sequential pins are otherwise adjacent. On a board layout looking down at the top layout the pads are numbered like this (or any consistent rotation):

2 4 6
1 3 5


Wire it like that and you should be able to plug in any programmer that supports ISP (e.g. AVRISP MkII, STK500, etc.)

• I see lots of boards that have a place for such a header (either rows of through-holes or rows of SMT pads) to be soldered to the board, but the header itself is missing. I assume that the manufacturer uses the pogo-pins mentioned by Joby to temporarily touch the programmer to those pads on the board. – davidcary May 29 '10 at 6:44

What you need is a surface-mount adapter. Then a ZIF socket is easy to find.

The QFP ones are kind of expensive, but you can get piles of most footprints pretty cheaply from Sparkfun or other sites.

• eBay is also a great place to get ZIF sockets and similar paraphernalia. – Dirk May 28 '10 at 13:27
• Not necessary -- it's generally much easier to do in-circuit programming on the board after the part is in place. – Jason S May 31 '10 at 23:47

In production we use these TQFP32 adapters we bought on ebay.

PS. We bought several more than we need so if anyone needs them with an EU VAT invoice... ;-)

I have had huge success with this setup.

An STK600 with TQFP32 Zif. This will allow you to program your chips via USB before putting them on the board.

In-system programming facility is a good idea. It'll also let you update the firmware if necessary. Other ways probably involve making a needle bed or a substitute for one.

As a compromise, you could make sure there are test points somewhere on the needed (GND, !RST, SCK, MOSI, MISO, +V) nets and make a needle bed to match those. Then you don't need an actual ISP connector/layout on board. You might extend that to do some automated production testing, too.

You talk about batches of >1, and then the following is probably not worthwhile, but it certainly is for larger batches, say 100 and up.

With In Circuit Programming you program the device after PCB assembly, so with the controller mounted on the PCB. On the bottom of the PCB I have test pads which bring the for programming required signals outside. Typically that's JTAG, but it could also be a serial port. Have the engineering department build a test jig with spring-loaded test pins matching the test pads.

You'll need test pins to supply power too. I usually add a few extra test pins for for instance measuring certain parameters, or a communication channel where the microcontroller can identify itself (think software version). You can't have too many test points. You don't need the space-hungry connector (which also costs money), and you can place the test pads wherever you please. There's always place for a 2mm pad.

The test jig costs in materials and labor, but you really need one if you have a large production, and then you might as well use it to program the device.
After programming you can boot the device on the test jig and perform a number of functional tests.