Main Site Documentation

I2C Scan


#1

I’ve placed some code: http://code.tinyclr.com/project/356/i2c-scanner/ for an I2C scanner.
I know that if the return code is unequal 0, then a device is on that address.
But several devices return several codes.

Question: who knows what the return codes mean?


#2

result (in your code) is the number of bytes written.
“The number of bytes of data transferred in the transaction”


#3

??? I’m not sure about that mrPositive.

The data written to the bus is always the same.
A PCF9531 returns number three (3).
A PCA8591 returns number two (2).
If is is the number of bytes transfered, why is it different on these chips?
There is no read, just an ACK. I will check your anser with my analyzer during the day.

Cu Wim.

Edit:
The procedure with an analyzer took place and see what happened:
Not two bytes and three bytes return.


#4

i wanted to take a look at the datasheets of the devices but can’t find the PCF9531


#5

I think it is PCA9531


#6

Indeed a typo.
It is a PCA9531 and a PCF 8591.
But this still leaves the question unanswered.

Cu Wim.


#7

The number you get is the number of bytes that was ACKed by the device at that address.

When you get a return of 2 you will see that the third byte was NACKed…

The scan code doesn’t make sense as it is for a scanner. You create an I2C_Device with address X, then you send the address X to the device and a byte 0?

You end up writing 3 bytes to the device. You only need to send one byte to see if it gets ACKed. That is also the safest. As the code is it will write garbage to a I2C_Eprom as the device address.(if eeprom is at address 0x91 on the bus then it will write zero into addres 0x91 of eeprom)