View previous topic :: View next topic |
Author |
Message |
evsource
Joined: 21 Nov 2006 Posts: 129
|
i2c addressing problem solved (2432.c) |
Posted: Mon Apr 16, 2007 5:17 pm |
|
|
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
|
|
|
evsource
Joined: 21 Nov 2006 Posts: 129
|
|
Posted: Mon Apr 16, 2007 5:27 pm |
|
|
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. |
|
|
|