CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Reading Long value from EEPROM no longer working...

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
seidleroni



Joined: 08 Sep 2008
Posts: 21

View user's profile Send private message

Reading Long value from EEPROM no longer working...
PostPosted: Mon Oct 27, 2008 9:30 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Oct 27, 2008 9:38 am     Reply with quote

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.

_________________
David
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group