NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Support Forum » char arrays problem
January 19, 2011 by stretch_pr |
Hi, I just finished the LED ARRAY Kit and I wanted to make a scroll based of char array. I have finished everything but the code works fine when I use:
but when use:
it doesn't work. Does anyone knows why? Here is part of the code:
|
---|---|
January 19, 2011 by mrobbins (NerdKits Staff) |
Hi stretch_pr, See this thread. Basically, you can edit your "Makefile" and remove the "-j .text" part from the avr-objcopy line. Then, recompile, and your original way of initializing the array should work. Mike |
January 20, 2011 by bretm |
Isn't the .text section the part that contains the actual program code? You need to add "-j .data" in addition to "-j .text". Or just leave the makefile alone and use PROGMEM and pgm_read_byte. |
January 20, 2011 by mrobbins (NerdKits Staff) |
Hi bretm, Yes, you're exactly right. However, simply removing "-j .text" and not specifying any sections makes avr-objcopy default to copying all sections. Mike |
January 20, 2011 by bretm |
Oh, that's handy. Does that imply that variables in default NerdKits sample apps don't get initialized to zeros (because .bss isn't included)? |
January 20, 2011 by mrobbins (NerdKits Staff) |
I believe I recall reading that the AVR hardware actually clears the SRAM to all zeros upon reset, but I could be mistaken. Also, variables that are local to a function scope are often allocated in registers instead of given a permanent SRAM location assignment, so these will be cleared by the program code in any case. |
Please log in to post a reply.
Did you know that interrupts can be used to trigger pieces of code when events happen? Learn more...
|