Week Seven: Embedded Programming

twinkle twinkle little LED...

Task

Read a microcontroller data sheet; program your board to do something.

Tools

Result

Here's a video of the light on my board blinking during button press:

Files

Here's the code:

Approach

Programming

I programmed the board in C by modifying the blink code. The LED blinks when you hold down the button.

After breaking my board in week 5, I knew I had to thoroughly modify the make file to work with the ATtiny44 (not the 168). Watch out for the fuses!

I uploaded my code using my FabISP and by running make, sudo make program-usbtiny-fuses (only the first time), and sudo make program-usbtiny from command line in the folder with the program files. I had previous renamed the makefile as "makefile" so I didn't need to include -f and the filename in the commands.

Identifying why things weren't working was the toughest part of the week--it was difficult to pinpoint hardware errors verses coding errors. Thanks to the TAs for help with this, especially Dan Novy.

To continue my R theme, I read up on ways to integrate R and C code. This was beyond my skill set and time commitments for the week. It's also a little unclear what you'd gain by pairing the two--they seem fairly redundant in functionality, though R is more accessible (certainly to me).

Trials and Tribulations

I attached my ISP and board incorrectly a few times. If your boards not talking to your computer always try flipping the header on one end of the cable. Make sure you don't also absentmindedly flip the board!

My circuit from week 5 wasn't entirely correct. The resistor on the button trace currently does nothing to prevent the button from floating. Fortunately the button was attached to a pin with an internal pull up resistor that I could use (programmatically) instead.

Initially I had my LED on backwards. It was hard to tell and this took awhile to debug because the line was a bit concealed by the soldering. Remember: line goes in the direction of the current (i.e. pin -> first LED side -> line LED side -> ground).

I tried using printf as mentioned in class for debugging, but it turns out that it's not supported on the ATtiny44. I could have implemented similar functionality by starting from the helloFTDI code, but didn't get to this--my problem ended up being hardware based anyway.

Reading the datasheet was somewhat helpful, but I found that I lacked the big picture intuitive understanding of the system, so the implications of the details were not clear to me.

Links