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 CCS Technical Support

i2c addressing problem solved (2432.c)

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



Joined: 21 Nov 2006
Posts: 129

View user's profile Send private message

i2c addressing problem solved (2432.c)
PostPosted: Mon Apr 16, 2007 5:17 pm     Reply with quote

I thought I'd try to save someone else the hours I've spent troubleshooting a simple problem. I'd consider it a bug in the code that ships from CCS.

When trying to use the i2c with an external EEPROM, such as the 24LC32, and the code that ships with CCS, 2432.c, things just don't work - at least *most* of the time (some intermittent successes). After staring at the bus signals on the o-scope (which looked like they were doing what they were supposed to), I started digging through the datasheet for the EEPROM and comparing with the code in 2432.c. Turns out, in the latest versions of the compiler, the following line doesn't work without some modification:

Code:
#define hi(x)  (*(&x+1))


This needs to be changed to:

Code:
#define hi(x)  (*((int8*)&x+1))


This might have been discussed in other threads, but I couldn't find them with a quick search. Hope this helps someone.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Apr 16, 2007 5:22 pm     Reply with quote

http://www.ccsinfo.com/forum/viewtopic.php?t=30393&highlight=2432
evsource



Joined: 21 Nov 2006
Posts: 129

View user's profile Send private message

PostPosted: Mon Apr 16, 2007 5:27 pm     Reply with quote

PCM programmer wrote:
http://www.ccsinfo.com/forum/viewtopic.php?t=30393&highlight=2432


As usual, my question could have been answered by looking through the forum more carefully.

Thanks PCM programmer.
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