Problem with constant lookup tables

Hi

I have a problem with some constant lookup tables. I am using Arduino-0012 (same problem on 0011) with a Diecimila board.
I am declaring around 500 bytes worth of constants in a number of separate arrays like this:

const byte someLookup[] = { 1, 4, 6, ...... };
const byte secondLookup[] = { 6, 5, 4, 12, 4, ... };

Each array is around 30 to 70 bytes long.

The program compiles down to 10588 (of 14336) using agv-gcc version 4.3.0. I am targetting an ATmega168.

When accessed, some of the array data appear to return the wrong values (!) If I re-organise the source code by swapping around the order in which they are declared, then the problem goes away from the original array, but appears in a different array. I therefore assume that their is some sort of location related problem.

Since we don't have access to the makefile within Arduino, I cannot find a way to generate listing or map files so that I could manually check what is going on by reading though the assembler listings.

Has anyone else had similar problems, or know how to generate listing/map files?

Thanks

I have a problem with some constant lookup tables.

It may be that you have a RAM overflow problem. Although you might conclude that defining the arrays as const would put them in Flash memory (as opposed to being in RAM), you'd be wrong.

Data tables such as this should be in Flash memory (the same memory in which your program resides) and can easily be placed there using the PROGMEM attribute, e.g.

#include <avr/pgmspace.h>
...
const byte someLookup[] PROGMEM = { 1, 4, 6, ...... };

Doing this avoids using up valuable RAM for constant data items but it does require that you use special functions to access the data elements. See the PROGMEM Help for more information.

Many thanks Don - that was indeed the problem.