I am a long time embedded SW engineer but new to the Arduino. I think I am up against memory constraints. I am using the Duemillinova with the ATmega328p chip. The basic functionality of my project includes:
An interface to a quaduture encoder (ISR is about 10 lines)
An Epson 132*132 LCD (Major hack of the James Lynch library to cut out wasted space)
A micro SD using FAT. (SD library is the one that comes with 0022).
Compiling all this together indicates I am using 17284 bytes of 30720. It will download but does not run more than a dozen lines before going off into the weeds. I will assume that I am running out or RAM as commenting out large chunks returns some functionality.
Questions:
-
Is a memory map generated someplace is you are using the Arduino IDE?
-
If I dropped to work with the uderlying compiler, could I get a memory map?
-
If there a “free Heap” routine? I found one at the Playground, but not sure of its heritage. (http://www.arduino.cc/playground/Code/AvailableMemory)
-
Does “const byte FONT6x8[97][8];” but this in the code segment as I would expect/hope or does it get put in RAM? If not, is there a way to force it? Including the font puts me over the edge and yet I would not expect it to take away from my RAM.
After more due diligance, I have found that “const byte” variables are not put into ROM but rather RAM. The font map I have for the LCD uses up 776 bytes of precious RAM that I need for SD FAT.
Any tricks for moving the font into ROM?
Is it possible to create an assembly routine, tell the compiler it is code, but reference it as data? Does the architecture support this? I know some processors can’t fetch data from program space. Is that the issue here?
I like the Arduino so I would hate to think I have gotten this far only to toss the Arduino for something with more “guts”.
After even more due diligance, I have found that you can indeed have inline assembler in an Arduino project. Two questions remain:
-
Can this architecture fetch data from ROM?
-
Does anybody have a sample of inline assembler to define a data block?
I think all my questions were answered by this web page: http://www.nongnu.org/avr-libc/user-man … space.html.
As a Havard Architecture processor, data and code are in seperate address ranges. That makes it difficult to put non-changing data into the FLASH. But, a series of macros and language extensions do exist to do exactly that.
I implemented the changes and it seems to work. Hope the following breadcrumbs helps someone else someday.
const
data in program space
inline byte definition