Help with ARRAYS required.

Hi ya

Using the UNO, I've successfully used PROGMEM to store around 24k of (recorded) sound data in an array to play back (at variable speed) in an engine sound simulator. I used approx 8k each for the 'start', 'run' and 'stop' samples and the program itself accounted for about another 6k of storage.

Flushed with success, I then decided I'd like to use a MEGA 2560 so I can use longer, higher bit rate sound samples - after all, there's now 256K to play with! Luckily I was able to borrow one to check the feasibilty of the idea before purchasing.

So I doubled up (copy & pasted) the 24k sound data just to check it out. That produced an "array too large" report, and after researching I found that arrays are limited to 32k - no problem I thought, I'll use three seperate (up to 32k each) arrays for the 'start', 'run' and 'stop' data. So I twice copied and pasted the 24k data, assigning unique names to the two new arrays. It compiles ok with no errors, but the compilation report still shows only the original amount of memory has been used (ie 24k + program).

Any guidance on where I've gone wrong would be very welcome!

Best regards

Alan

Any guidance on where I've gone wrong would be very welcome!

Not posting your code is a major error.

At a guess your have no code using the 2 new arrays and the compiler has optimised them away but post your code and we can see.

@UKHeliBob

Excellent guess - I was only checking to see if I could store the extra data but hadn't written any code to use the two extra arrays - and the compiler was too smart for its own good!

Entered a couple of dummy lines of code to access the new arrays and the memory useage has now increased to a sensible value. Thank you for your prompt and inspired guess.

Sorry not to have posted code as you suggested but I thought it might be a fundamental issue like a compiler issue - not sure where I found it now but the statement "arrays limited to 32k" might have meant that it was a compiler limitation for the total of ALL arrays used regardless of the chip storage capacity.

Thanks again!

Alan

not sure where I found it now but the statement "arrays limited to 32k" might have meant that it was a compiler limitation for the total of ALL arrays used regardless of the chip storage capacity.

What type of variable do you suppose is used as the index into the array? What maximum value do you suppose can be stored in that type?