# Why do we need hardware programmers?

I use a Boarduino and a 30-row bread board to program my ATtiny. I load a not too complicated sketch called ArduinoISP (included by default now in the Arduino IDE), and suddenly I have a working programmer. Atmel sells a nice programmer for between $30 and$40, and there are lots of kits for making cheaper ones.

I was very happy once I got my working programmer and made the tiny blink some leds. However, now my poor boarduino is stuck on programmer duty.

As far as I can tell this programmer holds down the reset button, and then transmits and receives on the MOSI and MISO pins. I think the SCK is unused or at least unneeded. (SCK is needed according to the ATtiny datasheet, my programmer doesn't work without it, and I can't find the place I thought I read it was not needed.)

Why do I need a hardware programmer to just transmit serial? I mean, let's suppose I am willing to hold down the reset button with my finger instead of using an IC. All that's left is serial send and receive, so all I need are three wires GND, RXD, and TXD. Heck, if I have the "DTR" line or whatever, you can even hold down the reset button with the serial cable.

Why are there all these hardware solutions that also require fancy software (like AVRdude, or AVR studio, or whatever)?

I mean I could understand a little USB cable that presented the microcontroller as a mass storage device and let you drag binary files over for programming (like this ARM dev board). Hardware only, using standard software drivers.

I could also understand a software only solution (modulo hooking wires from the USB to the chip, using something like the FTDI chip to simplify what goes down the wires). All of the fancy programming protocol would be handled by software on the computer, and the hardware would just be some wires.

Why do we have both (complicated) software and hardware involved? I mean, as far as I can tell, programming microcontrollers is pretty easy, but when I was just getting into this I was really worried about how I was going to ever buy a chip from mouser or digikey without paying some guru to program a bootloader for me.

I'm sure there is a good reason (it's not like I've written the software or started manufacturing the drag-n-drop USB programmer), but as a newcomer, I have no idea what it is.

• Does your home-brew hardware programmer allow debugging? You might be fine programming alone, but would need a hardware programmer if you wanted to do on-chip debugging (setting breakpoints in code and halting execution when you reach that point) as that operation might do funny things with the reset line. – Joel B Dec 1 '10 at 18:22
• Something that you may be amused by, hackaday.com/2013/05/10/… – binarysmacker Jan 5 '14 at 21:15

You are right, programming AVRs is pretty easy. It's just a custom protocol implemented on top of SPI, running at low voltage. SCK is needed.

However, programming older PICs (and non ISP AVR programming) requires high voltages and a different custom protocol. This necessitates a special hardware programmer.

Other devices are more complex. Most ARM microcontrollers must be programmed via JTAG, here memory is being written directly and the processor is instructed to write to the flash. Again, every device is different.

• Any ideas why those are so much more complex? The AVR way (Low voltage, standard protocol) seems so much more sensible than requiring a custom programmer (like this guy with an 8051/8052 programmer need - help wanted, rep available! electronics.stackexchange.com/questions/4104) – Kevin Vermeer Sep 30 '10 at 12:51
• There really isn't anything special or expensive about PIC programmers; many designs are available online, and most new PICs can be low voltage programmed. – akohlsmith Sep 30 '10 at 13:06
• IC manufacturers don't really care about how complex something is for hobbyists to use. As long as it can be used in large quantity production, it's otherwise all about cost. – endolith Sep 30 '10 at 14:00
• High-voltage programming was there first, it was the way to program UV-erasable EPROMs in the eighties (and microcontrollers containing such EPROMs). – starblue Sep 30 '10 at 18:36
• Fixed the SCK claim. I like the idea that only SPI is needed, but since computers don't have an SPI port (and heck the FTDI cable already has a $4 chip in it!!) we might as well splurge on a$2 microcontroller. The JTAG upload-and-debug argument has sold me on the benefits of a development board in general, and I think endolith has a good point that nobody cares what I spend my \$20 on; manufacturers care what real engineers (and their employers) are going to spend their budget on. – Jack Schmidt Oct 1 '10 at 0:46

I did a lot of research and am preparing to start playing with AVRs, but I never actually used one, so this may be wrong, but:

Most cheap programmers will not support AVR high voltage programming. It is needed if the controller is set to be nonprogrammable using fuse bits or if you somehow made some serious bugs and need to reset it to defaults and so on.

• Low-voltage programmers like the AVRISP mkII[1] or USBtinyISP[2] can be used to set fuses with avrdude or other programmers, but they can't save an AVR chip that's been made un-bootable or had its reset line turned into a GPIO. You do need an high-voltage programmer for that sort of thing. [1] mouser.com/search/… [2] ladyada.net/make/usbtinyisp – blalor Sep 30 '10 at 10:14
• @blalor In light of this information, I'll edit my answer. – AndrejaKo Sep 30 '10 at 10:18
• I did see some instructions on making a high voltage programmer (and the datasheet for the chip seems to have pretty detailed instructions on designing one), but I'm waiting until I brick one of my chips until I try it. My oscillators get here tomorrow, so I'll be burning fuses and tempting the brick fairy soon enough! – Jack Schmidt Oct 1 '10 at 0:49
• It's notable that avrdude double-checks your fuse bits to prevent this problem. A slightly more common problem is setting the chip to external clock. – Yann Vernier Oct 2 '10 at 8:50

Most cheap AVR programmers are just sync serial interfaces with a reset line. You can you an FT232 to bitbang out Serial Peripheral Interface(SPI). The FT232 is designed for async serial not sync so its all done in software.

You could just upload a bootloader like arduino which would allow you to upload code via the async serial interface using the ft232 in normal mode or any async serial interface using level converters as needed. Just don't forget to use the right bootloader for your clock speed and to set the fuse bytes correctly.

Many programmable devices have historically required that they be programmed using relatively-precisely timed sequences of signals. In many cases, if one only wanted to program one particular type of device, the required hardware would have been quite simple, but since different devices had different requirements, building a more general-purpose programmer was somewhat more difficult.

Today, one could probably program more than 50% of programmable devices using nothing more than a USB I/O cable and PC software, but "hardware" programmers still have a considerable speed advantage. For the PC to react to a signal received by a USB device and send a response generally takes a minimum of 1-2 milliseconds. If a programming sequence requires repeatedly asking a device when it's ready for the next chunk of data and then sending it, using a simple I/O cable would add an extra millisecond or two to the time required to handle each chunk. Depending upon the nature of the device in question, that could increase the overall time required for programming by an order of magnitude compared with a programmer which could be told, while waiting for a device to be ready, what it should do once it is.

Personally, I like the approach of having flash-equipped devices ship from the factory with a boot-loader in memory that can be used with a minimum of programming hardware. If the device supports flash programming under software control, such an approach may simplify production without adding anything to the cost of the silicon beyond the very small marginal time required to have the factory test fixture program in the boot-loader after it has done everything else.