Pololu USB AVR User Manual
Page 36

, this program will blink the red user LED. If you want to program an AVR that does
not have an LED connected to pin PD1, the LED-blinker code in this tutorial will have no visible effect.
If your device is an ATmega48, ATmega168, or ATmega328P, download the corresponding archive below:
• mega48:
(9k zip)
• mega168:
(9k zip)
• mega328:
(9k zip)
If your device is not one of the above, you will need to download one of the above archives and modify the makefile
to use your particular device.
Unpack the archive on your Linux computer. Copy the file
BlinkLED/linux/Makefile
into the
BlinkLED/
directory.
You will need to edit this file. Change all instances of “/dev/ttyUSB0” to the name of the programming port device,
usually /dev/ttyACM0. Additionally, it may be necessary to change the settings at the beginning to reflect the
locations where the AVR utilities were installed.
Note: You will probably want to edit BlinkLED.c slightly if the clock frequency of your AVR is not
20 MHz. F_CPU should be defined as the clock frequency of your AVR in units of Hz. If you do not
make this change, the timing of delayms() will be off, but the LED will still blink.
At this point, you should be ready to compile the example program and load it on to the AVR. Plug in the programmer
and type make. You should see output like this:
/usr/bin/avr-gcc -g -Os -Wall -mcall-prologues -mmcu=atmega168 -c -o BlinkLED.o BlinkLED.c
/usr/bin/avr-gcc -g -Os -Wall -mcall-prologues -mmcu=atmega168 BlinkLED.o -o BlinkLED.obj
/usr/bin/avr-objcopy -R .eeprom -O ihex BlinkLED.obj BlinkLED.hex
/usr/bin/avrdude -c avrispv2 -p m168 -P /dev/ttyACM0 -e
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.08s
avrdude: Device signature = 0x1e9406
avrdude: erasing chip
avrdude: safemode: Fuses OK
avrdude done. Thank you.
/usr/bin/avrdude -c avrispv2 -p m168 -P /dev/ttyACM0 -U flash:w:BlinkLED.hex
avrdude: stk500_2_ReceiveMessage(): timeout
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.03s
avrdude: Device signature = 0x1e9406
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "BlinkLED.hex"
avrdude: input file BlinkLED.hex auto detected as Intel Hex
avrdude: writing flash (224 bytes):
Writing | ################################################## | 100% 0.39s
avrdude: 224 bytes of flash written
avrdude: verifying flash memory against BlinkLED.hex:
avrdude: load data flash data from input file BlinkLED.hex:
avrdude: input file BlinkLED.hex auto detected as Intel Hex
avrdude: input file BlinkLED.hex contains 224 bytes
Pololu USB AVR Programmer User's Guide
© 2001–2014 Pololu Corporation
4. Getting Started in Linux
Page 36 of 54