News:

;) This forum is the property of Proton software developers

Main Menu

Verifying the i2c address of a device

Started by TimB, Jun 09, 2023, 07:08 AM

Previous topic - Next topic

TimB

Hi all

I assembled a PCB that had some Mchip DAC converters only to find I could not talk to them (again). It seems unless you are buying 100's Mouser, Farenell etc will ship you just what is on stock and that could have any address. Nothing on the packet you have to get the magnifying glass out and read the number on the chip and look it up in the data sheet.

Obviously its a pain in the rear so I want to automate it. On first power up it will check an eeprom address. If its $FF then it will call a routine to check each device in turn to figure out which of the 4 address's it is and save that to eeprom for the future.

Now my question is how to do that. I think I basically send an address and wait for an ACK back. Is that right? What is the method to test for it. Some good member said they wrote a prog to scan the i2c bus for all devices but not sure where that is.
Perhaps I should search for it my self ;)   But it would be nice to just have a simple explanation like send address then look for the SDA line to go low or something like that.

Cheers

Tim

DaveS

Hi Tim

I remember having to use something simliar to get the address of temperature sensors.

https://protoncompiler.com/index.php/topic,70.msg268.html#msg268

Dave

SCV

You can ping a device through the hardware I2c and test for the ACK bit (you don't say which device). But if I understand you correctly, how would you know what channel a seemingly random device is connected to? You could even have two devices with the same address...

You're best off physically sorting them.

Good luck.
Tim.

TimB

Thanks DaveS

That was the file from Keytapper had mentioned before but  could not find it.

SCV
Thanks I have software i2c routines it was just the process of determining if there was an ack. Reading online I think it is the following

BusStart
Send 8bits of the address MSB bit first then on the 9th clock check the SDA line. If its High then no response at that address.
BusStop

There are only 4 address's I need to check. As I have 4 devices with potentially the same address I control the A0 using a control line to each device

So its
Device 1 Active
Scan the 4 addresses
Note the address that responds save to Eeprom

Do the same for the other 3

I have to talk to a i2c 2x16 seg display and they are notorious for having different address for the PCF8574AT chip so the routine can be used for that as well :)