Darrel, I started this mess with a word sized address without highbyte, lowbyte. I found in another thread that the high-low byte addressing worked for someone, and when it didn't work for me, I made my first post in this tread with my code at the time.
However, I changed the 16F877 a third time and it's working! Is it possible that some PICs just don't work with I2C? Prior to finding a working 16F877, I tried two other 16F877's and a 16F876A. All failed to work properly.
Is it possible I had the circuit wrong? I can't go back and try a PIC that failed because they are all in their respective parts' bins with others of the same type. The most complicated part of my circuit is the MAX233, and it worked properly the first time. The 24LC256 is simple: Pins 1 to 4, and 7 to gnd, pin 8 to 5V, pin 5 pulled-up and to c.4, and pin 6 pulled-up and to c.3.
Anyway, thank you all. You kept me motivated to keep trying. All I can say to anyone reading this tread with a similar problem is just keep trying different components, and periodically, start your breadboarding all over again. As stated above I tried four different PICs, and I re-wired my circuit at least four times. This is the code that works:
Code:
@ DEVICE HS_OSC, WDT_OFF, LVP_OFF, BOD_OFF, PWRT_OFF, PROTECT_OFF
DEFINE LOADER_USED 1
DEFINE OSC 20
addr var word
edata var BYTE
addr = 0
edata = 50
pause 100
for addr = 5 to 10
I2CWRITE portc.4,portc.3,$A0,addr,[edata],Nowriteack
pause 10
serout2 portc.6,32,[dec addr,44,32,dec edata,10,13]
edata = edata + 10
next
for addr = 5 to 10
i2cread portc.4,portc.3,$A0,addr,[edata],NoREADAck
serout2 portc.6,32,[dec addr,44,32,dec edata,10,13]
next
end
NoWriteAck:
serout2 portc.6,32,["No Write Acknowledgement",10,13]
return
NoReadAck:
serout2 portc.6,32,["No Read Acknowledgement",10,13]
return
I've attached a picture, which was the objective of this exercise. It's rough, but at least I can move on to improvements and new challenges.
Bookmarks