program memory 32 bit unsigned int

I am have troubles either saving unsigned long values into progmem or having troubles reading it back.

Can some one tell me why I cannot save 32bit data to program memory and then read it back?
Below is the test program that I am exploring the problem with.


//const unsigned long paul1[] PROGMEM = {0xAAFF0A, 0xAAFF0B, 0xC, 0xD, 0xE, 0xF};
const uint32_t paul1[] PROGMEM = {0xFF0A, 0xFF0B, 0xC, 0xD, 0xE, 0xF};

int loopnum = 0;

void setup() {
while (!Serial); // wait for serial port to connect. Needed for native USB

void loop() {
loopnum ++;
Serial.print("Loop: ");

// read back a 2-byte int
for (int k = 0; k < sizeof(paul1)/4; k++) {
//Serial.println(pgm_read_word_near(paul1 + k)); // works for 16 bits
Serial.println(pgm_read_word_far(paul1 + k)); // trying to read 32 bits

Serial.print("Size of paul1: ");

// for (int k = 0; k < sizeof(paul1); k++) {
// Serial.println(pgm_read_word_near(paul1 + k));
// }


_far is for 32bit addresses. For 32bit data, you want pgm_read_dword_xxx()

Thank you westfw,

Your recommendation worked.
As a new person trying to make programs, how did you know this command/function. When I looked at the Arduino website under program memory I did not see that command.

Thanks for the help,

Take a look here: avr-libc: <avr/pgmspace.h>: Program Space Utilities