Step 10Program the microcontroller
To program the microcontroller, I use avrdude and the USBTinyISP programmer.
- http://savannah.nongnu.org/projects/avrdude/
- http://www.ladyada.net/make/usbtinyisp/
- http://www.adafruit.com/index.php?main_page=index&cPath=16
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
| « Previous Step | Download PDFView All Steps | Next Step » |
























































Since the author indicates chip destruction if not done correctly, is the character before the word "fuse" a lowercase "L" or an uppercase "I"? Big difference...
BTW, it is a lowercase "L".
I'm having trouble with setting the fuse bytes on my ATMEGA16 16PU.
I plugged the chip in, made contact with it, uploaded the hex firmware fine, but after I set the lower fuse byte I noticed my green LED connected to PB0 (pin 1) stayed lit and after I set the higher fuse byte it went out. I tried to reestablish contact with the chip again but it comes up with this error message:
"avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check."
I fear the chip is destroyed, but have no idea how since I followed the instructions and even copied and pasted the fuse byte code to be sure they're right.
Any ideas what could be wrong?
Stevie
I made the cube but not working only the status leds are blinking
i am using mega32 t i can use same fuse as 16 ???
in high only SUT0 is high and in low SPIEN ,BOOTSZ1 and BOOTSZ0 is high
please somebody :-(
I think you can use the same fuses, but you have to change the Makefile and recompile the software.
Change this line:
MCU = atmega16
To this:
MCU = atmega32
If you load the mega32 with firmware compiled for the mega16, it will work long enough for the status leds to blink, then reboot.
Remeber to post pictures and video when you get it working :)
makefile:1: *** missing separator. Stop.
when i type make :-(
or can u post firmware for 32????
http://cgi.ebay.co.uk/USBtinyISP-AVR-ISP-Atmel-Programmer-Arduino-bootloader-/170474128004?pt=LH_DefaultDomain_0
Since I live in Europe its a lot cheaper to buy this one than the one from the site. do you think this is compatible with avrdude. it seems to me that the components are the same, only in a different layout. thanks for the instructable
This is the one i made in 2 days. (programmer + Led cube)
After hour, nay days of work I'm stuck on the last few metres.
I've checked my circuits over and over again and cannot find a problem, but avrdude tells me there seems to be a connection problem, it fails to retrieve the uC signature. I used an ATMega16PU.
I'm using a http://www.matwei.de/doku.php?id=en:electronics:usbisp and this is some verbose output from avrdude.
I really hope somebody can tell me what might be the problem.
C:\Program Files\WinAVR\bin>avrdude.exe -c stk500v2 -p m16 -P com1 -vvvv
avrdude.exe: Version 5.5, compiled on Jun 9 2008 at 14:32:04
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
System wide configuration file is "C:\Program Files\WinAVR\bin\avrdude.conf"
Using Port : com1
Using Programmer : stk500v2
AVR Part : ATMEGA16
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PA0
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
eeprom 4 10 128 0 no 512 4 0 9000 9000 0xff 0xff
flash 33 6 128 0 yes 16384 128 128 4500 4500 0xff 0xff
lock 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
lfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
calibration 0 0 0 0 no 4 0 0 0 0 0x00 0x00
Programmer Type : STK500V2
Description : Atmel STK500 Version 2.x firmware
Programmer Model: AVRISP
Hardware Version: 15
Firmware Version: 2.10
Vtarget : 0.0 V
SCK period : 6.6 us
avrdude.exe: stk500v2_command(): command failed
avrdude.exe: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.
avrdude.exe done. Thank you.
Any ideas? Thanks in any case for the great instructable.
If I can find some webspace to host the files, I'll be happy to share my schematics. (I'm sure they're correct)