wrt eeprom values, the source has:

- Code: Select all

#pragma romdata pid_values=0xf00000

rom float pid_values[] = {

3.500, //Initial P value

1.875, //Initial I value

3.250 //Initial D value

};

#pragma romdata startup_temp=0xf0000C

rom signed int startup_temp[] = { 20 }; // Initial start temp value (/5)

#pragma romdata sleep_temp=0xf0000E

rom signed int sleep_temp[] = { 300 }; // Sleep temp value (times 2)

#pragma romdata boost_temp=0xf00010

rom signed int boost_temp[] = { 800 }; // Boost temp value (times 2)

#pragma romdata backglight_value=0xf00012

rom signed int backglight_value[] = { 50 }; // backglight value 0-100

#pragma romdata calibration_data=0xf00014

rom float calibration_data[] = {

0.75, // SLOPE (HAKKO ORIGINAL)

-207.00 // OFFSET (HAKKO ORIGINAL)

};

when you load hex it should show proper values. Float is 32bits in C18, so P=3.50 should be first 4 bytes.

0x00 0x00 0x60 0x40 = 0b00000000 00000000 01100000 01000000

so:

EXP = 01000000

byte0 = 01100000

byte1 = 00000000

byte2 = 00000000

Sign is 0

Exponent is 1

Mantissa is 1.11 (1+2^-1+2^-2 = 1.75)

2^1 * 1.75 = 3.5

so I'd say eeprom has proper values ... (as expected as it's put there directly by c18)

Now, it is possible that there's actually a bug in C18 here as I read in C18 lib that C18 stores floats different from IEE754 so it's not that exponent byte holds the sign and byte0 holds the 8th bit of the exponent (as we properly see here in the eeprom) but byte0 holds the sign while exp is a 8bit value of exponent. If this is true then C18 has a serious bug ..

What's worse, DS51297F-page 158 show that float is stored:

± e7 e6 e5 e4 e3 e2 e1 e0 d0 d1 d2 d3 · · · d23

and this coincides with what we see in eeprom

but, DS51288A-page 10 show that differently from normal IEE754 C18 stores floats as:

e0 e1 e2 e3 e4 e5 e6 e7 ± d0 d1 d2 d3 · · · d23

Now if this is true then we have a case where C18 stored one format in eeprom and is reading another format .. that does not make sense to me but since I can't test it attm ..

What do you read from hex? Are you sure you enabled your programmer to write to eeprom (by default that might be off)?