I2C_Address = I2C_Address +1
makes no sense at all, in pbp i2c address are 7 bits + r/w bit at bit0
so i2c write to $76 and to $77 are writes to the exact same address
I2C_Address = I2C_Address +2
will get a "NEW" address
I2C_Address = I2C_Address +1
makes no sense at all, in pbp i2c address are 7 bits + r/w bit at bit0
so i2c write to $76 and to $77 are writes to the exact same address
I2C_Address = I2C_Address +2
will get a "NEW" address
Warning I'm not a teacher
Hi Richard and thanks for the reply.
The I2C_Address = I2C_Address +1 is only to show that 16 bits of data work when I2C_Address is equal to $78, in other cases, it don't work.
Thanks,
Nuno
still makes zero sense .
if no slave device responds with an ack then the pbp code will terminate the transaction
sending data to random or incorrect address' will achieve and prove nothing at all
what are you really doing and what is the slave device , how is connected
Warning I'm not a teacher
richard's correct in that if I2CWRITE doesn't get an ACK in response to writing a byte it immediately sends a STOP and returns with the CARRY flag set.if no slave device responds with an ack then the pbp code will terminate the transaction
Unfortunately, it never checks the return value so it continues on with the rest of the bytes in the I2CWRITE statement (here you have four of them).
Since it just sent a STOP, it sends a START again, the next byte in the statement (which is now treated as a slave address), gets another NACK, sends STOP, etc, etc until all the bytes are sent.
It should really terminate the entire I2CWRITE statement when it gets a NACK to the the first byte (the slave address), but it doesn't... it just erroneously continues on writing what amounts to garbage to whatever "address" it runs across.
Not what i find . it may vary by pic18/16 and/or pbp versionUnfortunately, it never checks the return value so it continues on with the rest of the bytes in the I2CWRITE statement (here you have four of them).
i my test the transaction terminates at the first nak and is followed by a "funny start" dud transaction , the data in the sq brackets is never sent
pic18f45k80
editCode:'OSCTUNE.6 = 1 ; Enable 4x PLL OSCCON = 110000 TRISD=000110 'set PORTD define OSC 16 DEFINE I2C_SLOW 1 ADR VAR BYTE ADR2 VAR BYTE CMD VAR BYTE ADR=$48 ADR2=$70 SDA VAR PORTD.3 SCL VAR PORTD.2 CMD= $48 FEDO: I2CWRITE SDA,SCL,ADR,[5] I2CWRITE SDA,SCL,ADR2,CMD,[3,4] PAUSE 250 I2CWRITE SDA,SCL,ADR,[0] I2CWRITE SDA,SCL,ADR2,$48,[2,7] PAUSE 250 GOTO FEDO
might be a proteus artifact also, i have not scoped it
Warning I'm not a teacher
That produces a slightly different result, but it's still wrong... there are extra transactions after getting a NACK to the first byte (slave address).
"S 02 N P" shouldn't be there, and I have a hunch that if you change "ADR2=$70" to something else you'll find that is wrong too.
I didn't bother trying to figure out exactly what it's sending, but it's not really what's in the remaining I2CWRITE statement.
I looked at the asm code in both cases and there's nothing I see to look at the ack/nack result of sending a byte, except to send a STOP and reset the internal state so the next byte starts a new transaction. There's nothing to "skip over sending the remaining bytes" in the I2CWRITE.
Bookmarks