h o w > t o > m a k e :

sam calisch


week seven: embedded programming.

This week we programmed the ATTiny44 microcontroller on the Hello-FTDI boards we built in week five. The goal was to get a better understanding of the different components of the system, so we can program more exciting circuits to do more exciting things.

While this assignment wasn't the most inspiring ever, it was fun to finally see the electronics we've been producing put to good use. In particular, it was a chance to realize very stupid late night mistakes made several weeks ago. I forgot to think through the ciruit fully before ditching Dan's pull-up resistor in favor of the on-board one. After getting the error message below when I pressed the button with my board plugged into USB, I promptly smacked myself. Luckily, the board was easy to amend -- I cut off a trace and soldered a 10k in its place to limit current through the button when it's pressed.

After this initial trouble, it was reasonably smooth sailing. I downloaded CrossPack, and set out to run neil's echo program. I needed to do some cleaning because I had attempted to install the avr toolchain via macports a while back. Namely, run 'port uninstall avr-libc avr-gcc avr-binutils', because my machine was running the macports versions of these instead of the CrossPack versions. If you are in doubt, run 'which avr-size' for instance. The result should be '/usr/local/CrossPack-AVR/bin/avr-size', and not '/opt/local/bin/avr-size'.

Following neil's png, I made the hex code with no hiccups. I installed the pyserial module in order to run neil's term.py. Finally, to check the port, I tab completed 'ls /dev/tty.usb' to find the port, '/dev/tty.usbserial-FTF4ZHMI'. This matched system profiler, so I was sure I had the right one. Running term.py now, the communication looked good (see top image).

After that, it was time to make the button and LED do something. There's a nice tutorial from High-Low Tech for setting up the Arduino environment to program the Tiny44. If everything appears to work, except the clock appears an order of magnitude slow, make sure you remembered to burn the bootloader.

I started from one of the debounced button example script and changed the button's function to cycle through different PWM duty cycles for the LED. The sketch is linked below.


MAS.863 2012