This is a small introduction at working with attinies.
Update: Starting to use avr on ubuntu, see bottom of page.
Note: There are several ways of doing this
As i’m totally new to working with microprocessors, I needed some guidance (got that from Zevv, thanks Zevv for a simple approach with that Makefile) and set an easy goal: create a LED blinker.
For those interested in starting to work with small microprocessors, here’s how you can get something going with the Atmel AVR attiny (26 in this case)
Buy a breadboard, buy a programmer called usbasp, install drivers, I had to tweak it a little using a 64 bit driver for Windows 7, it seems to work fine now.
Here are the drivers I have found on the web: usbasp
Buy an atmel microprocessor, I bought an attiny26-16PU.
Atmel, see http://en.wikipedia.org/wiki/Atmel_AVR
Buy some inputs and outputs, like, leds or piezo elements, coz, otherwise there’s nothing to see, or hear. A LED test is called led blink, or led blinker (or blinkenlights ), it’s a like a ‘hello world’ program. See http://en.wikipedia.org/wiki/Hello_world_program if you don’t know what that is.
The avr.c program makes a LED blink randomly, nice to test with, easy to change if you want.
Get the datasheet for your avr, for instance this one for the attiny26-16pu
Datasheets are rather easy to Google.
Check environment variable PATH, it should be set by the WinAVR installer.
Just start a command line and type:
The first entries of your path on windows should point to WinAVR directories.
Test a command, type:
Time to connect the microprocessor to the programmer, so we can write a program to its memory. On attiny26-16pu, other attinies: other datasheet, probably means different pins.
Connect the pins of your programmer with wires as follows:
MOSI(1) on MOSI (1)
/RES(5) on RESET(10)
SCK(7) to SCK(3)
MISO(9) to MISO(2)
VTG/VCC(2) to VCC(5)
GND(4,6,8,10) to GND(6)
(the numbers on the left are those of the programmer, on the right are the pins of the attiny26, note that ofcourse, different microprocessors have different pinouts, read yours in your datasheet)
Now you should be able to read the avr using avrdude with the command:
> avrdude -c usbasp -p t26
When that completes correctly, you can just use the Makefile with the command:
> make clean
to erase all ‘made’ files, or:
to compile the program for the avr
> make install
to program the bin file to the avr.
When the bin file is programmed, it will start immediatly. Connect a led to any of the PORTA pins.
There’s a thing or two about VCC and GND, there’s power to the attiny chip,
and there’s power to the things that are being powered by the attiny chip.
You may want to read more about that, e.g. about high loads, you don’t want that on such a tiny chip.
Connect a LED with a resistor (so that you don’t blow it up with 5v) to pin 11, 12, 13, 14, 17, 18, 19 or 20, just pick one.
The sample program turns all pins of PORTA (the mentioned pins) on (0xFF) or off (0x00).
From there you can extend the program to your wishes, just read about how the PORTA register works in your datasheet, you can do a lot from there, bitwise.
As I said I am totally new to this, but it’s a good way to get started in a relatively simple way. Now i’m going to order even smaller attinies 🙂
Update: Starting to use avr on ubuntu
Get the packages needed to work with avr’s: the compiler, utils, libs etc:
apt-get install gcc-avr binutils-avr gdb-avr avr-libc avrdude
apt-get install make
download the avr.c mentioned above.
download the Makefile.txt (mv Makefile.txt Makefile , this is needed, note: capital M)
Use the commands: make clean, make, make install in the same way as the description for windows, see above.
I had to do this as root, because of the usb device not being accesible to the user account.
This is no security issue for me, hence I didn’t fix this.