Data Flash in Arduino With TWO diamentational array...

i used data flash memory to store my code big size of array in arduino pro trinket board i succesfully store using PROGMEM but i want to access one by one location..i use pgm_read_byte_far for access flash memory my problem is i pass array value constant so its give perfect value but i use increment operator and pass to array value access its give garbage or wrong reading..why?? suppose i write array

prog_uint32_t array[7][2] PROGMEM = {
{0,0x610000},
{1000,0x640000},
{1000,0x660000},
{1000,0x680000},
{1000,0x6A0000},
{1000,0x6D0000},
{1000,0x6F0000},
};

guValue = pgm_read_byte_far(array[guData][0]);
{
guData++;
}
its give garbage or wrong value but

guValue = pgm_read_byte_far(array[5][0]);

here instead of 5 any constant digit from array write its give perfect array access...
what is problem i also dump guData variable on terminal its increment one by one....at the start its guData=0;...

How is guData declared ?

uint16_t guData=0;...globally

Unless you are sure your object passes the 64k boundary, just use pgm_read_byte, however you are using uint32_t, so you need pgm_read_dword.

Also you need to pass the address of the element to read, you try access its value. See this small example.

const uint32_t array[7][2]  PROGMEM = {
{0,0x610000},
{1000,0x640000},
{1000,0x660000},
{1000,0x680000},
{1000,0x6A0000},
{1000,0x6D0000},
{1000,0x6F0000},
};

void setup() {
  Serial.begin(9600);

  for(char i = 0 ; i < 7 ; ++i ){
    for(char j = 0 ; j < 2 ; ++j ){
  
      Serial.print( pgm_read_dword( &array[i][j] ), HEX );
      Serial.print(',');
    }
    Serial.println();
  }

}

void loop() {}

New IDE's do not know the prog_xx_t types, just use the normal type, and make it const.

Thank u so much ....

mangukia:
how to access array without pgm_read_dword...
i just want to access array
const uint32_t array[7][2] PROGMEM = {
{0,0x610000},
{1000,0x640000},
{1000,0x660000},
{1000,0x680000},
{1000,0x6A0000},
{1000,0x6D0000},
{1000,0x6F0000},
};

void setup() {
Serial.begin(9600);

for(char guData= 0 ; guData < 7 ; ++guData )
{

uint32_t guValue=array [guData] [1] ;
Serial.println(guValue);
}

while i use uint32_t guValue=array[5][1];..its give correct value but above give garbage...flash access without pgm_read_dword keyword or function

The compiler does not know about PROGMEM, its a linker thing.

uint32_t guValue=array[5][1];

What is happening is the array indices are constants so the optimizing compiler will not keep the array, but put the value of array[5][1] inline. So reading from PROGMEM is not necessary.

It effectively optimizes to:

uint32_t guValue=0x6D0000;

In the loop the indices are deduced at runtime and will give garbage as the storage is in PROGMEM, not RAM. The pgm functions are required to access the different storage space.

If you turned of all optimizations, the constant version should fail too. So basically, if you mark something as PROGMEM, use the correct functions, one day after an update or change to your code, you could end up wasting a lot of time trying to work out what is happening.