Checked it. It fails on the first write statement.
Checked it. It fails on the first write statement.
Fails on the second statement if I swap the values of Addr. i.e. First $37, second Addr $36. First one goes fine.
Okay let's fix that first.Checked it. It fails on the first write statement.
Put brackets around the Loc as shown in the PBP manual to see if that helps.
Code:Main: High Led : Pause 500: Low Led : PAUSE 500 Addr=$36 I2CWRITE SDA,SCL,ADDR,[LOC],Fail ' Test here first Addr=$37 ': pause 10 ' OR If SDA=1 then main I2CREAD SDA,SCL,ADDR,[LOC,VALUE] ',Fail PAUSE 25 DEBUG HEX Value,13,10 PAUSE 250 DEBUG "Done....",13,10 WHILE 1 : WEND Goto Main Fail: toggle portc.2 goto main
Last edited by LinkMTech; - 27th July 2013 at 19:56. Reason: Reply timing!
Louie
I did exactly the same as above and the sequence completed fine. BUT the values are not consistent with the datasheet, I should get '$2E' from location 0, but WHATEVER location I try to read, I am getting '$FF'
Have a look at my real term serial monitor. I am actually getting a lot of unexpected data which I don't understand how is getting stored in just one byte. Though among all this, I can see '2E' (but it is swapped around so 'E2'). Note sure if I am trying to convince myself or the data is rubbish.
Better in nibble setting. I can see '2E' repeated a few times.
My bad, change the Read statement:
Code:I2CREAD SDA,SCL,ADDR,[VALUE] ',Fail
Louie
Still getting the same with the following code:
Code:Value Var BYTE Addr Var byte Loc Var Byte '--------------------------------------------------------- Pause 500 DEBUG "Start......",13,10 Value=0 Loc=0 Main: High Led : Pause 500: Low Led : PAUSE 500 Addr=$36 I2CWRITE SDA,SCL,ADDR,[LOC],Fail1 Addr=$37 : pause 10 ' Sometimes it is failing, leaving pause 10 makes it better. I2CREAD SDA,SCL,ADDR,[VALUE] ,Fail2 PAUSE 25 DEBUG Value,13,10 PAUSE 250 DEBUG "Done....",13,10 WHILE 1 : WEND Goto Main Fail1: while 1: toggle portc.2 : pause 50 : wend goto main Fail2: WHILE 1 High Portc.2 : Pause 250 : Low PortC.2 : Pause 250 WEND
Bookmarks