Nope I found that mistake of mine earlier and fixed itIf you are still using the schematic from MeLabs then...
Yeah this one amazes me with PBP having an I2CREAD and a I2CWRITE command but yet you still have to tell it to READ or WRITE?!?!?!The other thing I see in the data sheet is the last bit of the control byte sets Read or Write.
0 = READ
1 = WRITE
Just to clarify I found this under section 5.0 saying that a READ operation should be a 1 and WRITE should be a 0
The last bit of the control byte defines the operation to
be performed. When set to a one, a read operation is
selected, and when set to a zero, a write operation is
selected.Yes I believe so because the 24FC1025 only has a 5ms delay neededPAUSE 10 'Is that long enough?
I tried it and got the same results, nothing but 255's.And you may have to add this but try the above stuff first
DEFINE I2C_SLOW 1
Do you know if the 24FC1025 is flashed with all 0's or all 1's from the factory? Before I was getting %00000000 from var B1 and now I am getting %11111111 but I want to know if its actually reading that or if its a blip in the coding.
Here is the updated code:
I added a 2nd byte to check an address I have not written to and also get a 255 from that but early on in the code I set B1 and B0 to 0 and its getting changed somehow. So either I am reading all 1's from the addresses or the code is screwy.Code:DEFINE I2C_SLOW 1 SO con 0 ' Define serial output pin T2400 con 0 ' Define serial mode contR CON %10100001 ' Define Control byte contW CON %10100000 ' Define Control byte addr CON %0000000000000111 ' 2 Byte Address of 7 D1 CON %00000111 B0 VAR BYTE ' Var for data being read B1 VAR BYTE ' Var for 2nd byte being read b0 = 0 b1 = 0 I2CWRITE PORTB.1,PORTB.4,contW,addr,[D1] ' Send the byte 1 to address 7 PAUSE 10 ' Wait 10ms for write to complete I2CREAD PORTB.1,PORTB.4,contR,addr,[B1,B0] ' Read address 7 into B1 ' and address 8 into B0 Serout SO,T2400,["Addr",#addr,":",#B1," and then ",#B0,13,10] ' Print
PS sorry about the novel here, but its late and I tend to ramble when I'm tired.
Other notes:
I am using a 4MHz external clock to run the show if that matters. I will be switching to a 20MHz once I have everything working.
Bookmarks