Working with AVR-gcc, tiny13, STK500 on a Mac.

11 02 2008

First, install the packages (avr-gcc, binutils etc) for compiling/linking AVR programs in Mac OS X. I followed the instruction here: Programming an AVR microcontroller

Afterward, it is time to start my first led program in C.

I decide to use PB0 as led output, I connect the PB0 to Led0 on STk500 to start this testing program quickly.

#include <avr/io.h>
#define F_CPU 120000
#include <util/delay.h>
int main (void)

// set PB.0 as output pin

DDRB  = 0x01;

// set PB.0 to output high

PORTB = 0x01;

while (1) {

PORTB ^= 0x01;




Compile the program:

avr-gcc led_blink.c -o led.elf -mmcu=attiny13

Convert the elf format to hex format for flashing to the Tiny13:

avr-objcopy -O ihex led.elf led.rom

Prepare avrdude for Mac to flash program and find out the serial port device name on your Mac OS X. I am using usb2serial adapter, the serial port device is /dev/cu.usbserial and connected to stk500 RS232 CTRL port with the serial cable provided in stk500 kit.

avrdude -p t13 -c stk500v2 -P /dev/cu.usbserial -e -U flash:w:led.rom

If it programs successfully, you will see the LED0 is flashing on STk500 board.


Programming AVR ATtiny13 with STK500

11 02 2008

The STK500 comes with a manual with all the instructions for programming the AVR processors. The only problem is that I want to use it to program the AVR tiny13 which is not yet ready when the time the manual was printed. After searching on the web, I found out that the instructions are ready on the help page of the latest AVR Studio for Windows. Finally, I can program my AVR tiny13 with STK500. I am using my Mac to program the AVR tiny13, so I better write it down here. Hope it may help you also.


Step 1 – Place the ATtiny13 (DIP) to the SCKT3400D1.


Step 2 – Connect the ISP6PIN socket to SROG1 with the 6-pin cable provided.


Step 3 – Connect the PORTE/RST to PORTB/PB5 and also PORTE/XT1 to PORTB/PB3. I used the 2 pin cables provided, it is a bit lossy.