Many newcomers to AVR programming would love to build their own low-cost programming device, but they face a chicken-and-egg problem: many of the designs themselves use an AVR microcontroller; this needs to be programmed, and so they first need to make a programmer...
This is where the SCAP (Serial Cheap AVR Programmer) can come in handy. It is a very simple programming device using a minimum of components, and it can be connected either directly to a PC's RS-232 interface or to a USB interface via a USB-to-RS232 converter.
The circuit includes a nine-way D-sub socket (K1) which can be connected to the PC's serial port or to the USB-to-RS232 converter. The circuit takes advantage of the internal protection diodes on the AVR's I/O pins to V cc and GND, and the two series resistors R1 and R2 are thus needed to limit the current flowing through these diodes. The values are chosen to keep this current below 1 mA. The RS-232 interface can be as high as ±15 V. At -15 V the AVR's internal protection diode to GND limits the voltage on the I/O pin to a minimum value of -0.7 V, while at +15 Vthe protection diode to V cc limits the pin voltage to a maximum value of V cc +0.7 V. Now, because the values of the series resistors R1 and R2 are relatively high, the charging and discharging of the AVR's input capacitance is considerably slower than if it had been driven directly by a push-pull stage, and this limits the maximum permissible frequency on SCK for reliable operation. The wiring of K2 corresponds to the standard six-way Atmel ISP connector.
The well-known open source program AVRDUDE is an essentially universal programming tool that can very easily be configured to work with SCAP: see [1] and [2]. The configuration file avrdude.conf needs to have the following section added to it:
This adds a new programmer called 'scap', which can then be selected as the device to be used for programming using the command-line option '-c scap'.
Even though the reset pin of the microcontroller is tied permanently to GND in the circuit, it must still be defined for AVRDUDE. If AVRDUDE fails to establish a connection with the AVR device to be programmed, the power to the device must be interrupted briefly to cause it to perform a power-on reset. Here is a sample command to invoke AVRDUDE. We have assumed that SCAP is connected to COM1 with an ATmega8 as the taret device (this corresponds to the commandline option '-p m8') and thatthe hex file to be programmed istest.hex.
avrdude 300 -
-P coml -p m8 -c scap U f lash : w : test . hex : i
The instruction to slow down SCK is specified by the command-line option '-i 300', which gives a delay of 300 jlls. This makes the programming operation rather slow. Depending on the type of interface used (normal RS-232 or a USB-to-RS-232 converter) it may be possible to reduce the delay value to as little as 50, which will make programming faster. If SCAP is being used just to solve the chicken-andegg problem mentioned at the start of this article, then programming speed will not be of any great concern
Internet Links
[1] AVRDUDE:
www.nongnu.org/avrdude/
[2] AVRDUDE version for Windows: www.mikrocontroller.net/ attachment/69851 /avrdude-5.1 0.zip
No comments:
Post a Comment