How to cook AVR microcontroller?
(Only tested for AT90S1200, AT90S2313, ATtiny2313 and ATmega8.)
What is microcontroller? Why AVR?
It's a frequent problem that one have to build fast a simple digital circuit.
To solve the task, you can choose elements from SN74*** (or other) digital
circuit collection, you can buy the one-chip-circuit if it exists (it can be
expensive), or buy a simple microcontroller (for 1.5 - 2 €) and compose a
program for it.
The microcontroller is a complete computer that has only few periphery connecting
with the world. These "computers" has a simple 8 bit CPU, they are working with
few kBytes of program memory, few 100 Bytes of RAM (if it has any) and they
operates with 1 - 10 MHz of clock frequency.
There are lots of microcontrollers developed by different manufacturers on the world,
but if we want to use them, we should use theirs own developing software and own burning
tools of the microcontroller. These can be so expensive.
For the Atmel AVR
microcontroller architecture there are several free developing utilities.
The official developping tool is Avrstudio that operates with M$ Windows.
But if I want to burn the developped software do I have to buy the official burning
tool for about 100 €? Hmmm...
There are developing tools for AVR architecture which are operating with UNIX operating
systems, eg. tavrasm and avr-gcc. Hooray! The developping of microcode can move in a
rut in UNIX environment. The task is only to burn it physically to the microcontroller...
The burning hardware
The AVR microcontrollers can be programmed in two way: high voltage programming or low
voltage programming mode. The high voltage programming mode means that the RESET pin
have to be pulled up to 12V and the program and address bytes can be sent in parallel ways.
If we use low voltage programming we don't need 12V supply voltage and the burning hardware
can be realized simpler, but the programming goes in serial way and some bits (eg. fuse
bits) cannot be set by using this serial method. For these reasons the programming time
could take more minutes.
The realized AVR programming system applies the high voltage programming mode.
The hardware onsists of a simple supply voltage generator, a simple adapter circuit that can
communicate with the PC. The simplest way to realise the adapter circuit is using a
microcontroller. For this the AT90S1200
was choosen. That is fully compatible with AT90S2313 and ATtiny2313.
There is the shematic view:
The 8 data bits of the LPT port are all connected to the microcontroller to be burnt, and the first two bits of this data byte
are also connected to the driver microcontroller. This way data sent to the parallel port of the
PC is aimed either for the driver microcontroller or for the microcontroller to be burnt. The
driver microcontroller always knows which byte is for itself and which byte is meant for the
microcontroller to burn, and it gives control signals to the other IC only when the byte is a
data, an address or a command byte for the chip to be programmed.
The role of IO pins can be changed easily from software, so the connection routing is only
optimalized for the simpler printed-circuit.
There is the image of printed-circuit:
To help connecting parallel port pins to the hardware: parport.html
The driver program
You can download here:
This source contains the source of firmware and some documentation (shematic view and printed-circuit layout).
To compile the program use "make" and install it "make install" command. You will need tavrasm, latex and ghostscript-gnu
(dvipdf) package. (Latex and dvipdf only needed for the documentation, you can compile and use the raw program without them.)
See help menu (-h) :-)
Please chech if the version of firmware match with the program before using (see -v).
Chick or egg?
Oooops! To get the burner be able to work a burner is needed.
This paradox is resolved:
The AVR microcontrollers can be programmed in serial way too. Look at the circuit! The D0 and D1
pin of lpt line are connected to PB5 and PB7 pin of the driver microcontroller. These pins used
during serial burning (MOSI and SCK pins).
Burning the firmware
- Pull out the jumper near pin 18 (STROBE bit)
- Put a jumper near pin1 (RESET pin)
- Become "root"!
- Use the command:
avrburn --update-firmware /usr/local/share/avrburn/avrburn.bin
- You will need to pull out and then put back the RESET jumper (the program will tell you when).
- Wait until ends. It can take more then 10 minutes