5.4. Compiling an example program in Mac OS X

A simple demo program is supplied in the directory libpololu-avr/examples/atmegaXXX/simple-test/, where atmegaXXX is the processor on your board.

Open a terminal window and navigate to this directory. You should be able to compile the example with the supplied Makefile by typing make at the command prompt. This will produce a file named test.hex which is ready to be flashed to your AVR.

Now connect your programmer to your Mac and your Orangutan or 3pi robot, and turn on the device’s power. If you are using the Pololu USB AVR Programmer, the green USB LED should be on and the yellow LED should be blinking, indicating that the programmer is ready.

Open the Makefile in a text editor. You will need to change the PORT variable to refer to your programmer’s programming port, as determined in Section 5.1 (e.g. /dev/tty.usbmodem00022331).

To load the example program onto your device, type make program. Some seconds later, you should see output from AVRDUDE that looks something like this:

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e950f
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 "test.hex"
avrdude: input file test.hex auto detected as Intel Hex
avrdude: writing flash (3392 bytes):

Writing | ################################################## | 100% 0.88s

avrdude: 3392 bytes of flash written
avrdude: verifying flash memory against test.hex:
avrdude: load data flash data from input file test.hex:
avrdude: input file test.hex auto detected as Intel Hex
avrdude: input file test.hex contains 3392 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.72s

avrdude: verifying ...
avrdude: 3392 bytes of flash verified

avrdude: safemode: Fuses OK

avrdude done.  Thank you.

If your controller was successfully programmed and you are not using a Baby Orangutan, you should hear a short tune, see the message “Hello!” on the LCD (if one is present and the contrast is set correctly), and the LEDs on the board should blink. If you are using a Baby Orangutan, you will just see the red user LED blink.

Note for Orangutan SVP and X2 users: AVRDUDE has incorrect chip erase delay settings for the ATmega324P, ATmega644P, ATmega1284P. This means that when you try to program, the erase operation will take longer than AVRDUDE expects and AVRDUDE will interpret this as an error. The workaround is to find the AVRDUDE configuration file, avrdude.conf, and increase the chip erase delay for the m324p/m644p/m1284p to 55000. The file is located in /usr/local/CrossPack-AVR/etc/ in Mac OS X.