- Install software package
sudo apt-get install gcc-avr avrdude avr-libc binutils-avr
- AVR Program
Open your favorite editor and type following code, and save it as led.c
#define F_CPU 1000000UL #include #include int main( void ) { DDRC = 255; while (1){ PORTC=255; _delay_ms(200); PORTC=0; _delay_ms(200); } return 0; } It is a good idea to have Makefile for compiling the c code. Download and extract Makefile file and use the Makefile available inside the archive. This make file was generated MFILE tool under windows 7. Copy Makefile and led.c file to a given folder and run following command on the terminal make allYou can use "make", "make all", "make clean" and "make program" commands
r USBasp programmer to the computer and the microcontroller. Then run following code for downloading, sudo avrdude -p m32 -c usbasp -e -U flash:w:led.hex in above code -p followed by m32 is for part number ATmega 32A; -c is for providing the programmer's name (hardware programmer); -e is to erase the device before programing; -U is to provide progrming location (in this case flash in write (w) mode has been selected) |
reference: https://fos.cmb.ac.lk/esl/programing-avr-ubuntu-14-04-usbasp/ , :avrdude Linux man
No comments:
Post a Comment