0

The USART-based bootloader is probably the most popular way of burning code to the AVR. The Arduino, for one, uses this method.

For example say you were using a FTDI cable to talk to your Arduino. First the USB connector end of the cable would go into your host computer. The other end of the cable would then be plugged into the appropriate header of the Arduino. The RXD line from the FTDI cable now connects to the AVR’s TXD pin. The TXD line connects to the AVR’s RXD pin. In this way, the software serial interface on the host computer is converted down to its wire line equivalent for communicating with the bootloader on the AVR. Even the USB versions of the Arduino burn code effectively the same way – that is they still use a USART-based bootloader.

But how do you reset the AVR so you can drop it into the bootloader and burn your code? One way is to use a third wire from the serial port, namely the DTR signal wire, to do it. The Arduino places a capacitor between the DTR signal and the AVR’s reset pin and its pull-up resistor. When the DTR line is toggled a pulse is generated causing the pin to go low and the AVR to be reset. Your own personal AVR circuits can be designed to use this method as well, using a pull-up resistor and capacitor.

However, this requires three wires, not including ground, as well as code on the host computer to toggle the DTR signal.

Instead of using three wires, the circuitry illustrated above uses only two: the TXD and RXD wires. With this circuit the AVR is reset whenever a modem break is sent over the host’s TXD line. The RST line goes directly from the 556 to the RESET pin of the AVR with no pull-up or capacitor in between.

When prototyping saving one wire might not be worth it, but if your microcontrollers were to be remotely controlled or placed a good distance away from each other saving a wire might come in handy. In addition your development board no longer needs either the pull-up resistor or the capacitor.

Here is a command sequence that you can use to reset and burn the AVR with this reset method. Note, the ~# escape sequence sends a modem break over the serial port.

$ echo ‘~#~.’ | cu -l /dev/ttyUSB0 -s 9600
$ avrdude -c avrisp -b 9600 -P /dev/ttyUSB0 -p m328p [hexfile]

Unfortunately the ‘cu’ command is slow to return the command line, so the alternate technique below is recommended.

$ echo ‘~#~!avrdude -c avrisp -b 9600 -P /dev/ttyUSB0 -p m328p [hexfile]‘ | cu -l /dev/ttyUSB0 -s 9600

Have fun!

Share