PDA

View Full Version : I2CREAD doesn't send stop bit



makobd
- 1st October 2011, 09:00
Hello!


I'm facing problem with i2cread function.
Seems that pic is not sending "STOP" code after "NOT ACK" code and reading continues.
So, without proper stop bit its impossible to start new i2cread sequence(second doesn't work at all)
Doesn't matter if its STR function or just one variable
eeprom is 24c32
i2c_dev is BYTE
i2c_addr is word

Here is the "read" code->



serial_read:


i2c_dev = $A0
i2c_addr = 3
I2CREAD porta.6, porta.7,i2c_dev,i2c_addr, [str line1\2]




i2c_addr = 19
I2CREAD porta.6, porta.7,i2c_dev,i2c_addr, [str line2\2]


return


Can anyone help?

Thank you!

mackrackit
- 1st October 2011, 13:31
Your code looks ok with the exception of a PAUSE 10 between the two reads. Do you have the CLOCK and DATA pins pulled up?

makobd
- 1st October 2011, 16:42
Thank you for fast reply!

It's impossible to get to second read line because is no stop bit at first.
Code works but doesn't stop.
Example:
if i'm reding from adress "X" and i want to read 1 field , because lack of stop bit reading continues until bit 5 from "X+6" address and no chance for second read line to work correct(pause between is irrelevant).
All values that was read in the faulty process are correct.

mackrackit
- 1st October 2011, 18:06
I must be missing something in the translation.
How do you know it does not stop reading? Where is it reading to?

Might be a good idea to post your code.

makobd
- 1st October 2011, 22:58
PicSimulator I2C eeprom have nice diagnostic where you can follow bit by bit transfer and whole reading sequence.
I have Line1[10] and Line2[10] arrays that i'm displaying on 20x2 LCD.
I think i will try with other EEPROM maybe 24c04.

Thank you!

mackrackit
- 1st October 2011, 23:09
Never trust a SIM.
And if I am not mistaken, PicSimulator is for the other PicBasic, not PicBasicPro..
Exactly what are you using? Proton? PBP?

makobd
- 3rd October 2011, 08:55
I'm using PBP.
Thank You!