« senn px100s + ipod mini == israeli disco? | Home | more wet »
June 13, 2008
uC programming: the real(ish) deal
the arduino is great but i wanted to dig a little deeper, and set some constraints. so i got ahold of an attiny13, an avr chip (like the atmega168 in the arduino) with only 1K of program flash. i acquired and soldered together the tools needed to program the chip and got under way.
one thing that became immediately clear: it's rather hard to debug. i've developed a flashing LED method of debugging, sending myself various pulse-based codes. not as efficient as a serial port.
another thing i ran into: the size of the .hex file is not hte same as the program size! I was trying to keep the .hex file under 1024 bytes, and it turns out, that's about 400 bytes in flash. score! i can relax a little about the size. a little.
luckily, avr's datasheets are quite nice, and i'm not having a lot of trouble interpreting which bits in which register do what. there's always fine print, of course. but that's not so bad.
my first project was a thermistor and a LED, hooked up so the LED would flash according to the temperature (now that I know I have more than 1K for the .hex file, I might look at a 7 segment).
the most irritating problem i encountered was this: i have a lookup table with 78 entries. when indexing to around 10, it would quite often inexplicably index 70 or so. i couldn't figure out why, but on a hunch, i split the tables into two tables of less than 65 bytes each. that seemed to fix the problem. no doubt if i read the datasheet a little more closely i'd discover why.
anyhow, it works now more or less. my next task is to get it running on 3V, then on a 3V battery, then into an enclosure to annoy my workmates.
Leave a comment