Go Down

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

David Randall Stokes

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.

Thanks,
Stokes

dh1ao

just an idea

long is usually signed
dword is unsigned

maybe? ::)
Erkläre es mir, ich werde es vergessen. Zeige es mir, ich werde es vielleicht behalten. Lass es mich tun, und ich werde es können. Indisches

David Randall Stokes

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.

Thanks!

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy