LED Cube 8x8x8

 by chr
Contest WinnerFeatured

Step 46: Program the AVR with test code

test_prog1.png
test_prog2.png
test_prog3.png
Time to test if your brand new LED cube actually works!

We have prepared a simple test program to check if all the LEDs work and if they are wired correctly.

You can download the firmware test.hex in this step, or download the source code and compile it yourself.

As in the previous step, we use avrdude for programming:
  • avrdude -c usbtiny -p m32 -B 1 -U flash:w:test.hex

-c usbtiny specifies that we are using the USBtinyISP from Ladyada -p m32 specifies that the device is an ATmega32 -B 1 tells avrdude to work at a higher than default speed. -U flash:w:test.hex specifies that we are working on flash memory, in write mode, with the file test.hex.
 
Remove these adsRemove these ads by Signing Up
wong1275 says: Jan 22, 2013. 2:06 AM
Hello,

I've successfully set the fuses and flashed my ATMEGA32 with the test.hex code, but when I power on, STATUS2 flashes on and off, then STATUS1 comes on and stays on (or flashes faster than I can see). Does anyone have any idea what this might mean?

Thanks!
stroodlemuffin says: Feb 14, 2012. 6:42 PM
I was able to upload and execute the test.hex program, but I had to hit the RS232 button to make it go; however, I am not using an RS232 cable. I uploaded the main.hex code and main.epp code but I got nothing from my cube upon pressing the RS232 button. Anyone have a fix?
triumphtotty in reply to stroodlemuffinFeb 15, 2012. 5:17 AM
The source code for text.hex wasn't released, but possibly it runs if EITHER button is pressed.  My best guess is that the wiring for your start button is incorrect.  Check SV1 and SV2.  Do both status LEDs flicker at startup?  Check BTN1 thoroughly by following the wiring from GND to the microcontroller.  One side of BTN1 should go to GND, the other to Pin 16 on SV1.  Pin 16 on SV2 should go to Pin5 (PB4) on the ATmega32.  Check that out.
stroodlemuffin in reply to triumphtottyFeb 15, 2012. 6:25 AM
I'll try that asap. What is the value of the resistor that goes from pin 9 (reset) of the Atmega32 to VCC? I currently have a 100 ohm resistor placed there as I could not get a definite value from this tutorial.
triumphtotty in reply to stroodlemuffinFeb 15, 2012. 7:02 AM
100 Ohm is far, far too low I think. 10K is recommended. I think I used 3K3 because I had them lying around, but 100Ohms dropping 5V will draw 50mA from Vcc when the programmer is trying to bring the system into _RESET_. It's only a signal wire, not a current carrier. Try something a bit bigger, and hopefully that will help!
stroodlemuffin in reply to triumphtottyFeb 16, 2012. 3:32 PM
It works great now, thanks! Was the cube set up so that you have to press button 1 to make it start? Because I hit restart and nothing happens but then when I hit button 1 the program starts. Don't really care, but just curious.
triumphtotty in reply to stroodlemuffinFeb 17, 2012. 12:04 AM
Yes! When you power the cube up the two status LEDs should flash. You either press BTN1 to start the internal effects, or BTN_RS232 to switch into RS232 "slave" mode. So glad it's all working now. Well done!
natekling says: Jan 11, 2011. 12:52 AM
Is there a C code example file?

Thank you.
fluetke in reply to nateklingJan 10, 2012. 5:52 PM
(removed by author or community request)
triumphtotty in reply to fluetkeJan 11, 2012. 6:09 AM
The full C source code is available in Step 49: Software Introduction. Most of the hard work is done by draw.c, and effect.c has some great code in it. main.c has the interrupts and startup code in it.
berto147 says: Jan 8, 2012. 7:38 AM
when using command - avrdude -c usbtiny -p m32 -B 1 -U flash:w:test.hex
it replies with error opening test.hex: no such file or directory
I have downloaded the test.hex file and saved it , is there a specific location I need to save this file to in order for it to be read
triumphtotty in reply to berto147Jan 9, 2012. 4:15 AM
It should be in the current folder as you type the command. Are you working in Linux or Windows?
berto147 in reply to triumphtottyJan 9, 2012. 4:39 AM
i am working in windows
triumphtotty in reply to berto147Jan 9, 2012. 5:15 AM
Depending on where the file is, you'll need to "cd" into the directory.

e.g. if it is on your Desktop in a folder called 8x8x8 then type:
cd Desktop\8x8x8

then type your command.

If it's somewhere messy, e.g, just create a new folder in C:\ called 8x8x8 and move/copy the test.hex file into it, then type

cd \8x8x8

before typing the avrdude command.

Hope this helps.
berto147 in reply to triumphtottyJan 9, 2012. 6:33 AM
i will try this on friday , i have had to go to scotland to work for a week , many thanks for your help
00cwilkr says: Jul 6, 2011. 6:17 AM
hi mate your link to test.hex doesnt go anywhere?
TechNotes in reply to 00cwilkrAug 12, 2011. 1:14 PM
What you do is right click on test.hex, and select "Save Link As...", then save it to wherever you want.
mnpumar says: Aug 8, 2011. 6:41 PM
Does anyone know where to put temp.hex in windows or how to specify the path?
TechNotes in reply to mnpumarAug 9, 2011. 5:58 AM
What you do is right click on test.hex, and select "Save Link As...", then save it to wherever you want.
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!