Go Down

Topic: pgmspace.h: reading 'long' values? (Read 783 times) previous topic - next topic


I'm trying to use PROGMEM to store a bunch of 32 bit values. In the sketch, these are type long. I'm the using pgm_read_dword() function to read the values and casting this to a long. I seem to be getting weird results. Aren't long and a double word both 32 bits?

Am I missing something basic? I can start doing a bunch of bit-by-bit dissection and printing to the serial console, but I wanted to make sure it wasn't something obvious first.



just an idea

long is usually signed
dword is unsigned

maybe? ::)


I put in a bunch of Serial.print() statements and found the problem... it was elsewhere in the code. :-[ Using pgm_read_dword() to get long values works just fine.

I'm just using the values as sets of bits rather than actual numbers, however, so I cannot say whether signed vs. unsigned will make a difference. If the bits come through intact, then the numbers should work as well if cast correctly.


Go Up