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.
Bookmarks