I2C: 5 devices, 4 addresses, minimum faff

Started by MrStab, March 17, 2024, 04:05:59 PM

Previous topic - Next topic

MrStab

Hi!

The Facebook groups for embedded tips seemed a bit spammy and typo-ridden. So I have sought help from you guys, the masters. Yes, this is pedal-related.

I have 5 identical I2C devices (AD5263), but only addresses 0-3 are hardware-configurable via. 2 address pins on each (AD0 and AD1).

A multiplexer or SPDT IC for that last pest would be a tad cumbersome. A software I2C bus (in addition to the 48-pin STM32's solitary hardware I2C) just for that outlier would also feel a bit excessive. As would increasing to a 64-pin MCU with two hardware I2C busses.

So is it feasible to just hook up the address pins on 2 of the AD5263's to a couple of the MCU's I/O pins, and flip as needed? Or do these need to be fixed upon power-up? Can't really find anything about "hot-swapping" them on the datasheet.

Input appreciated.


-G
Recovered guitar player.
Electronics manufacturer.

ElectricDruid

I dunno, but it certainly sounds like it's worth an experiment. TBH, I don't see why you'd design it so it *wasn't* possible to do what you suggest. After all, running out of I2C addresses is hardly unforeseeable if you only have four of them. So you design the chip so you can hack around it if necessary. Or at least, that's what I would have done. Since I'm betting those people are sharper than me, I'm betting that's what they did too.

0.02€.

Tom

MrStab

Thanks, Tom. It's for a 4-layer board design on which 95% of the circuitry is confirmed solid, bar this, so just trying to figure out if it's a fatal flaw the best I can in advance.

"The five MSBs are 01011 and the following two bits are determined by the state of the AD0 and AD1".

Really clutching at straws when inferring this, but that last phrase is the most definitive statement I can find that suggests it may be possible to flip the address while the bus is idle. Maybe I can find an application note or anecdotal experience with this or a similar AD chip if I dig hard enough.
Recovered guitar player.
Electronics manufacturer.

ElectricDruid

Can you not test *just that one thing* on the breadboard? Ok, building the whole thing might be a bit of a pain in the ar$e, but building just enough to see if the two low address bits can be used as "chip select" needs a lot less. I notice from looking at the datasheet that the AD0 input is *explicitly* used as a ~CS in SPI mode, so I wouldn't be surpised if it functions very similarly in I2C mode. At least, the signs are good!  :icon_biggrin:

MrStab

Quote from: ElectricDruid on March 17, 2024, 09:27:35 PMthe AD0 input is *explicitly* used as a ~CS in SPI mode, so I wouldn't be surpised if it functions very similarly in I2C mode

That's quite an interesting and encouraging point!

I may have to test it in isolation, but at £8.17 exc. VAT a pop and without too much free time on my hands as it is while doing bread & butter builds, it would be a bit of a pain. Including a footprint for an SPDT or jumpers for software I2C as backup would be easier, all things considered. TMUX6219 is quite a handy and predictable IC for the former.
Recovered guitar player.
Electronics manufacturer.

MrStab

Recovered guitar player.
Electronics manufacturer.

ElectricDruid

Quote from: MrStab on March 19, 2024, 07:40:03 PMIt's advised against by an AD rep here (albeit with a different IC):

https://ez.analog.com/temperature_sensors/f/q-a/564408/change-address-of-ad7415-after-power-up-dynamic-i2c-address

Awww, boo!
Well, you either have to go off-piste, or you need more I2C outputs, or you need a different chip.

pruttelherrie

Could you power the chips from an I/O? So you could reset them to read the new address.