Matt Groh

Embedded Programming

This week we're programming the printed circuit boards that we designed, milled, and soddered two week ago. For practice, I did everything over again. Here's a picture of a couple milling attempts, the finished board without components, and the board with the components soddered on.

Wee, sleeket, cowran, tim’rous beastie,
O, what a panic’s in thy breastie!
Thou need na start awa sae hasty,
Wi’ bickerin brattle!
I wad be laith to rin an’ chase thee
Wi’ murd’ring pattle!

That's the start of a poem about how things do not always go as expected. I put my ATTiny44 on backwards. Orientation matters! The little dot corresponds to pin 1, and pin 1 is the VCC (the Voltage at Common Collector or positive supply voltage). So, I took out the heat gun (see below) and removed the ATTiny44. I then desoldered the traces of solder. And, I re-soddered. And, now it appears like me might be back in action.

So, here's the set up to load code. We connect the board to a programmer (the USB AVRISP XPII) through the board's ISP. Then, we connect the FTDI headers to a power source. The black wire corresponds to ground. Orientation matters, remember ;).

Before we load code, we need to install dependencies, which we can do with Homebrew on a Mac. Here's the commands to install the right dependencies and make the hello world example.

brew install avrdude
brew tap osx-cross/avr
brew install avr-gcc
mkdir week6
cd week6
curl > hello.ftdi.44.echo.c
curl > makefile
Okay, cool. We've created a hex file! Now, it's time to load it onto the PCB, which should be as easy as

make program-avrisp2
But, alas. When, its oriented appropriately, I get an error that it's oriented in reverse. When, it's oriented in reverse, I get an unknown error.

But Mousie, thou art no thy-lane,
In proving foresight may be vain:
The best laid schemes o’ Mice an’ Men
Gang aft agley,
An’ lea’e us nought but grief an’ pain,
For promis’d joy!

Still, thou art blest, compar’d wi’ me!
The present only toucheth thee:
But Och! I backward cast my e’e,
On prospects drear!
An’ forward tho’ I canna see,
I guess an’ fear!

The next step would be to make a button blink. The code is posted here. I suggest using version 2. For my board, I simply have to switching the buttons and pins to correspond appropriately. Pin 5 (PB2) goes to the LED and Pin 6 (PA7) goes to the button. The datasheet of the ATTiny 44 said this is cool!