Reading Long value from EEPROM no longer working...
Posted: Mon Oct 27, 2008 9:30 am
Here is the function I use to read a 'Long' value from the EEPROM:
Code:
long ReadLong(int nAddr)
{
int i;
long data;
for (i = 0; i < 2; i++)
*(&data + i) = read_eeprom(i + nAddr);
return (data);
}
It used to work in an old compiler version (last 3.x compiler version published). Now I am using the latest compiler version (4.081). The 2 values in the EEPROm which it is looking at are:
At address 27: Value is 152
At address 28: Value is 08
Long value = 256 * (08) + 152 = 2200, but when I put in a printf statement to find out what value its finding, it tells me that the value is just 152. Is there something wrong with the function, or is this a CCS issue?
drh
Joined: 12 Jul 2004 Posts: 192 Location: Hemet, California USA
Posted: Mon Oct 27, 2008 9:38 am
This is from the readme file:
Quote:
Users that have old code with expresions of the form:
*(&data + i)
need to change them to:
*((int8 *)(&data) + i)
A compiler change was made to be ANSI compliant.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum