Saturday, 11 June 2011

Atmega32 programming with Linux



There are a lot of ways to program an Atmega chip on Windows using N number of GUI tools - popular ones being CodevisionAVR for STK500 programmer board, then eXtreme burner for USBasp programmers, KazamaAVR and so on.

But i have compiled this tutorial for the people who love the tux.  


Starting off with the Hardware required

1. Programmer Board/your own customized development board
2. DAPA Cable (Direct AVR Parallel Access)

 The schematic diagram of DAPA cable
3. Atmega32 chip (obviously)
4. Power Supply (obviously)


My DAPA cable (Sorry i dont have a good quality camera at the moment)

The software you will need
 
1. avr-libc
2. binutils-avr
3. gcc-avr
4. avrdude/uisp

If you are using Fedora or Red Hat a simple yum install will do the trick. Similarly for Ubuntu users apt-get should do it.

1. First we write a very simple code making all the pins of Port B high (my LED's are connected to Port B).
 
The avr/io library is responsible for the input output considerations of the chip.
DDRB register specifices the direction of Port B 0 for input and 1 for output.

 2. Now we use avr-gcc compiler to compile the progam. The -Os parameter is for compiler optimization. Without using this the compiler may issue a warning in cases where avr/delay library is used




3. Now we convert the .o to .hex ; Note that you cannot execute this file as ./ledtest since it is specifically compiled for atmega32 chip.


4.Now we upload the hex file on the chip using avrdude


Note: You might get an error 

Then you need to change the rights by becoming the root user


5. You can erase the chip independently.



6. You can use uisp (universal isp) instead of avrdude. A simple yum install uisp should install it.





No comments:

Post a Comment

Popular Posts