Home


Week Seven: Embedded Programming

I programmed the board to record a short sequence of button-pushes and play them back on the LED:

As a first step I downloaded CrossPack, which gives you all the packages you need to do AVR development.

Then I downloaded hello.ftdi.44.echo.c and hello.ftdi.44.echo.c.make and tried programming the board according to the instructions here. I borrowed Palash’s AVRISP mkII (thanks Palash), because my own FabISP never worked even though I'd been able to program it.

The program was made correctly but setting the fuses failed:

The problem was that I was running program-usbtiny-fuses, but was using using an AVRISP, not a USBtiny connector. So instead I ran

make -f hello.ftdi.44.echo.c.make program-avrisp2-fuses

and

make -f hello.ftdi.44.echo.c.make program-avrisp2

which successfully programmed the board.

A second issue was that once programmed, the chip was not showing up as a serial device on my computer, but was on someone else’s computer with the same FTDI cable. It turned out I needed to install FTDI drivers.

Without drivers:

With drivers:

And the echo program works (running screen /dev/tty.usbserial-[ID here] 115200):

And I can turn on the LED:

Next I started trying to figure out how how to add a bootloader so I wouldn’t have to remake my nonfunctional FabISP. It turns out Atmel doesn’t provide one for the ATTiny line. Various people have made their own, which is cool. However, I decided to get the assignment working before spending time working on that (and potentially bricking my chip).

So, I made another FabISP. This time it took about an hour, faster than the last one, and fortunately it worked.

I wrote the button-push-recording program in C using Sublime, which was fine for something this simple (~50 lines of code in one file), but Eclipse would have been better.

It's a small state machine that waits for a button press, samples the button state at about 20 Hz for five seconds and stores the results in an array, holds the LED off for a moment to signal it's done recording, plays back the sequence, and then goes back to waiting for a button push.

Some useful references (may be out of date):

AVR GCC Manual

ATTiny44 Datasheet

avr/io.h