Go Down

Topic: 1024 byte array (Read 1 time) previous topic - next topic

kngpengwin

I've been noticing some odd behavior when trying to use an array of 1024 (or more) bytes. arrays or data structures initialized after the large array return incorrect values, specifically values from the end of the large array.

I'm declaring and initializing the array like this:
byte myArray[1024] = {0xFF, 0xFF, ...etc };

is there some buffer I'm overrunning? is there a better way to initialize the array (ie with a delay, or in two parts)?



mem

#1
Apr 09, 2008, 04:43 pm Last Edit: Apr 09, 2008, 04:44 pm by mem Reason: 1
the arduino Atmega168 chip only has 1024 bytes of RAM and some of that is used by the startup code. You will need to reduce the size of the array.

ckiick

Hi,
  Yes, the RAM on an arduino is limited to 1K (at present).
However, if the data in the array is read-only (that is, you initialize it but don't change it), then you can use some of the program space to store the data.  This is called progmem.  Since the program space is 8k (for the 168 chip), you have a lot more room to mess around with.
Look here:
http://www.arduino.cc/en/Reference/PROGMEM
for details.
Chris J. Kiick
Robot builder and all around geek.

westfw

Grr.  I can understand why the compiler can't tell exactly how much ram is used, but you'd think it would be able to come up with some warning message if the ram used by a single source module exceeded what was on the chip...

mellis

There may very well be an option for it, but I don't know what it is.  If anyone feels like digging through the gcc / g++ man pages, I'd be grateful.  It's certainly something that would be nice to provide better errors for.

kngpengwin

ah, that makes sense. thanks for the tip, it looks like PROGMEM will do what I need to do.

follower

Quote
Since the program space is 8k (for the 168 chip)

I think you'll find it's actually 8KB for the ATmega8 and 16KB for the ATmega168.

--Phil.

CasNet

Greetings,

Maybe an external serial SRAM like the Maxim DS1200 could fit the bill here -- trading off 3 pins for 1024 bytes of storage.

Regards,
David

kg4wsv

Well, I was excited for a minute.  Check that DS1200 data sheet again - 1024 bits, which is only 128 bytes.

Ramtron has an FRAM, nonvolatile and they claim more than 109 write cycles.  I think the sizes are up to 256k bytes?  SPI interface.  Could be useful, but I haven't had a prject that required it yet.

There's a company that has a datasheet for a product that's an SPI interfaced SRAM.  I say they have a datasheet and not an actual product, because I can't find anyone to sell them to me other than a distributor who sells in 10k quantities with an unknown ship date. :|

-j


Go Up