I’ve placed some code: [url]http://code.tinyclr.com/project/356/i2c-scanner/[/url] 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.
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.
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)