NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Microcontroller Programming » AVR Arrays?
April 09, 2010 by Hexorg |
I've been trying to make this code work for the whole day already... what irritates me the most, same code works great on pc with a few little modifications. Code:
for some reason all 6 LEDs start glowing and don't blink at all. if i change led_out to
And remove some headers, it can be compiled and runs perfectly on pc, but I can't seem to find the error. |
---|---|
April 12, 2010 by hevans (NerdKits Staff) |
Hi Hexorg, I didn't really comb through the code, but could the problem be the that you are statically initializing arrays in your code. With our Makefile set up like we do, you can't statically initialize arrays. This is a result of the AVR architecture which has separate memory spaces for RAM and your program. There is a lengthy discussion about it in this thread. The easiest way to find out if that is the issue is to remove the -j .text from the avrdude flags in the Makefile, and recompile. This will cause avrdude to send all the data including the instructions on how to initialize your arrays in RAM. Note that you arrays will then be defined both in RAM and Flash, which is can be an issue in memory constrained environments. The better solution is to define your arrays in program space, then copy them over when needed. There is a great explanation of that on the avr-libc Data in Program Space page. Sorry if you already knew that. I'm starting to sometimes lose track of who has been involved in which conversations with all the awesome members on the forums! Humberto |
Please log in to post a reply.
Did you know that the Timer/Counter modules on the microcontroller can be configured to output a PWM (Pulse Width Modulation) signal? Learn more...
|