Step 10: Program the microcontroller
To program the microcontroller, I use avrdude and the USBTinyISP programmer.
First off, Let's just see if we can make contact with the AVR.
Connect the programmer to your cube and your computer.
The command is "avrdude -c usbtiny -p m16", wherer -c specifies the programmer, and -p the AVR model. You can see the output in the images below.
Now, upload the firmware: "avrdude -c usbtiny -p m16 -U flash:w:main.hex".
By now, the cube should reboot and start doing stuff. It will be running at 1mhz (very slowly) using it's internal oscillator. And some of the leds won't work, because some GPIO ports are used for JTAG by default.
To enable the external oscillator and disable JTAG, we need to program the fuse bytes:
run "avrdude -c usbtiny -p m16 -U lfuse:w:0xef:m"
and "avrdude -c usbtiny -p m16 -U hfuse:w:0xc9:m".
Be carefull when doing this step! If you get it wrong, you can permanently destroy your microcontroller! If you are using another microcontroller than the ATMega16, be sure to read the datasheet carefully before changing the fuse bytes!
After writing the correct fuse bytes, the cube should reboot and start operating at regular speed with all leds operational.
Enjoy your new cube :D