I was thinking to shift to linux and i'm doing this in "packets" after "packets"...
Using backtrack (ubuntu). So to start with AVR on linux you need some libraries and their dependencies to download. Finally you need atmegaX MCU and a burner. I'm using low cost usb-asp In System Programmer (ISP).
Software:
1. binutils: The GNU assembler, linker and binary utilities
2. gcc-avr: The GNU C compiler (cross-compiler for avr).
3. avr-libc: Package for the AVR C library, containing many utility functions.
4. uisp: A Micro In-System Programmer for Atmel's AVR MCUs (for burning code to MCUs' memory).
5. AVRDUDE: AVR programmer software that supports a wide variety of programmers.
Hardware:
1: AtmegaX : I'm using Atmega 16 microcontroller
2. AVR-Asp: A low cost in system programmer. (I got one from nex-robotics.com)
3. Target Board: You can make one of ur own or you can buy online.
Now Write a Programme in terminal or whatever you like:
sample:
* ledblink.c, an LED blinking program */
#include
#include
void sleep(uint8_t millisec)
{
while(millisec)
{
_delay_ms(1);/* 1 ms delay */
millisec--;
}
}
main()
{
DDRC |=1<
while(1)
{
PORTC &= ~(1<
sleep(100);/* 100 ms delay */
PORTC |=(1<
sleep(100);/* 100 ms delay */
}
}
// end of program.
Save the program with name "led.c". And compile it with
Compile the code:
In the above command atmega16 defines the target mcu.
0s code optimization level.
led.c is the input c code that we've just written.
led.o is the output binary file.
Generate hex code:
led.o is the output file from previous operation.
led.hex is the hex file that we've just generate using the above command.
Erase target MCU:
-e specifies erase the flash memory of the target MCU.
Burn Hexfile to MCU:
-U flash:w:led.hex specifies Write flash memory with the with the hex file followed by the command. In this case it is led.hex.
Using backtrack (ubuntu). So to start with AVR on linux you need some libraries and their dependencies to download. Finally you need atmegaX MCU and a burner. I'm using low cost usb-asp In System Programmer (ISP).
Software:
1. binutils: The GNU assembler, linker and binary utilities
2. gcc-avr: The GNU C compiler (cross-compiler for avr).
3. avr-libc: Package for the AVR C library, containing many utility functions.
4. uisp: A Micro In-System Programmer for Atmel's AVR MCUs (for burning code to MCUs' memory).
5. AVRDUDE: AVR programmer software that supports a wide variety of programmers.
Hardware:
1: AtmegaX : I'm using Atmega 16 microcontroller
2. AVR-Asp: A low cost in system programmer. (I got one from nex-robotics.com)
3. Target Board: You can make one of ur own or you can buy online.
Now Write a Programme in terminal or whatever you like:
sample:
* ledblink.c, an LED blinking program */
#include
#include
void sleep(uint8_t millisec)
{
while(millisec)
{
_delay_ms(1);/* 1 ms delay */
millisec--;
}
}
main()
{
DDRC |=1<
while(1)
{
PORTC &= ~(1<
sleep(100);/* 100 ms delay */
PORTC |=(1<
sleep(100);/* 100 ms delay */
}
}
// end of program.
Save the program with name "led.c". And compile it with
Compile the code:
avr-gcc -mmcu=atmega16 -Os led.c -o led.o
In the above command atmega16 defines the target mcu.
0s code optimization level.
led.c is the input c code that we've just written.
led.o is the output binary file.
Generate hex code:
avr-objcopy -j .text -j .data -O ihex led.o led.hex
led.o is the output file from previous operation.
led.hex is the hex file that we've just generate using the above command.
Erase target MCU:
avrdude -c usbasp -p m16 -P /dev/ttyACM0 -e
avrdude is the application that handles IO (input/Output) interfacing between MCU and computer.
-c usbasp specifies the type of the programmer used. In my case i'm using "usbasp" programmer.
-p m16 specifies the target MCU. "m16" denotes "atmega16" in this case.
-P /dev/ttyACM0 specifies the where the USB programmer connected to the linux pc. In my case it's "/dev/dev/tty/ACM0"
-e specifies erase the flash memory of the target MCU.
Burn Hexfile to MCU:
avrdude -c usbasp -p m16 -P /dev/ttyACM0 -U flash:w:led.hex
That's all and your program will be written into MCU's flash memory. And it'll self reset and will start execute the program.
Enjoy..










