Pages: [1]   Go Down
Author Topic: pgmspace.h: reading 'long' values?  (Read 457 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

0
Offline Offline
Jr. Member
**
Karma: 2
Posts: 81
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

just an idea

long is usually signed
dword is unsigned

maybe? :smiley
Logged

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

0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Pages: [1]   Go Up
Jump to: