Changing I2C address pin states on the fly - Page 1
Forum section: electronics / projects

author: GrantIsCoolAllegedly
author_rank: Newbie
timestamp: March 19, 2024, 10:35:20 pm
content: Hi!I intend to use the AD5263 digipot IC in a design. For I2C mode, each chip has two address pins, allowing for addresses 0-3 to be used. However, I need to use 5 of the chips.It would be a bit cumbersome and increase cost/complexity/BOM to add a multiplexer or standalone I2C bus just for that one outlying chip (be it bit-banged or a larger 64-pin STM32 with two hardware I2C busses). So I'm wondering if anyone knows whether it's permissible to change the state of address pins AD0 and AD1 while the circuit is powered up and the bus is idle, by connecting them to some MCU IO pins.I can't really find anything on the datasheet, though someone did point out to me that one of the pins is used for CS when configured for SPI mode, from which it can be loosely inferred that it might work.Any input appreciated!-G

author: PCB.Wiz
author_rank: Super Contributor
timestamp: March 19, 2024, 10:39:29 pm
content: Try it and see ? If the pins are simple digital it is unlikely they added more parts to latch them.Addit : I see that part has daisy chain SPI mode, so that might use fewer pins ? Just put 5 in a chain.

author: GrantIsCoolAllegedly
author_rank: Newbie
timestamp: March 19, 2024, 11:00:23 pm
content: I'll have to run tests if I can't find anything definitive - just trying to see if I can do so before forking out for a sacrificial digipot!Complications with using SPI are that the LQFP-48 variant of the STM32L5 seems to only have one hardware SPI feature, which I need for a display, and each daisy-chain path needs a pullup resistor.Going for the 64-pinner is an option but does encroach on separation of mixed signals due to its increased size.

author: langwadt
author_rank: Super Contributor
timestamp: March 19, 2024, 11:14:11 pm
content: Quote from: GrantIsCoolAllegedly on March 19, 2024, 11:00:23 pmyou can easily bit bang the spi bus

author: GrantIsCoolAllegedly
author_rank: Newbie
timestamp: March 19, 2024, 11:25:52 pm
content: I could, and it's one approach to consider. But it would be even easier to change 2 output pin states.

author: GrantIsCoolAllegedly
author_rank: Newbie
timestamp: March 19, 2024, 11:33:41 pm
content: Hmm... not the same part, but an AD rep advises against it here:https://ez.analog.com/temperature_sensors/f/q-a/564408/change-address-of-ad7415-after-power-up-dynamic-i2c-addressBit-banging or muxing may be the only recourse.

author: PCB.Wiz
author_rank: Super Contributor
timestamp: March 19, 2024, 11:59:12 pm
content: Quote from: GrantIsCoolAllegedly on March 19, 2024, 11:33:41 pmNote that part is not digital address pins, it uses a trinary coding scheme, so that is likely to need a test and decode step.Quote from: GrantIsCoolAllegedly on March 19, 2024, 11:33:41 pmSuch tests are unlikely to damage anything.Worst case I can imagine is they might capture the address pins on START, but that will not bother you here.If you needed to save wires/pins, a remote single gate inverter could support two banks of 3 parts, using a single MCU pin, and taking 00b as the never-used park address.

author: GrantIsCoolAllegedly
author_rank: Newbie
timestamp: March 20, 2024, 12:49:50 am
content: Ah, okay - I must still assume that absence from the AD5263 datasheet similarly means "undefined behaviour" in hardware terms, though (ie. prone to the "subject to change" smallprint).I'm starting to think bit-banging either SPI or I2C just for that one digipot would be the most appropriate solution. Four writes to a device wouldn't be particularly disruptive compared to the alternatives.Food for thought. Thanks!

author: PCB.Wiz
author_rank: Super Contributor
timestamp: March 20, 2024, 01:14:22 am
content: Quote from: GrantIsCoolAllegedly on March 20, 2024, 12:49:50 amJust remembered there is another trick I've seen, which is connect a second bank, with swap of SCL and SDA pins, as most i2c parts can tolerate and ignore backwards pins.Well suited to SW i2c.Some new MCUs even allow this in HW config.This from EFM8BB52 dataQuote

author: pcprogrammer
author_rank: Super Contributor
timestamp: March 20, 2024, 07:15:45 am
content: Even if the chip allows dynamically setting the address pins, I don't think it would solve your problem. Taken 5 of these chips are connected to your I2C bus, so two will always have the same address, when you set four of them with fixed addresses and one with two pins connected to the MCU. What ever address you now select with the MCU it will match one of the other four. Thus addressing that one will result in two chips to acknowledge the master. Not a big problem when writing, but they will receive the same setting. More of a problem when reading and get a mixed answer. (Collision on the SDA line)So you would need to reserve one of the addresses to be used for multiple IC's and one for parking the others. As such needing more MCU pins to change the addresses on more IC's.And with two pins on the MCU for addressing one of the chips you can just use these two pins to bitbang I2C for the fifth IC. Also allows you to use more of these IC's

author: PCB.Wiz
author_rank: Super Contributor
timestamp: March 20, 2024, 07:49:28 am
content: Quote from: pcprogrammer on March 20, 2024, 07:15:45 amWith a parked address (eg 00b) there are 3 valid ones left, and you can manage two banks with just a single pin + remote inverter*, supporting 6 active addresses.* I'm not sure an inverter is mandatory, if the park address is 00b on one part an 11b on the other.

author: pcprogrammer
author_rank: Super Contributor
timestamp: March 20, 2024, 09:50:37 am
content: Quote from: PCB.Wiz on March 20, 2024, 07:49:28 amI see what you are going for. But the combinations I tried don't make it work.Say you hook A0 or A1 of each IC to the MCU, 3 directly and 3 via an inverter, and connect the other line to either ground or supply (0, 1). Then the following applies.MCU pin = x inverted = yCode:A1 A0IC1 0 xIC2 1 xIC3 x 1IC4 0 yIC5 1 yIC6 y 1Now fill in for MCU pin is 0Code:A1 A0IC1 0 0IC2 1 0IC3 0 1IC4 0 1IC5 1 1IC6 1 1You can only safely address IC1 and IC2.Fill in for MCU pin is 1Code:A1 A0IC1 0 1IC2 1 1IC3 1 1IC4 0 0IC5 1 0IC6 0 1Now you can only safely address IC4 and IC5.So clearly this does not work.With another setupCode:A1 A0IC1 0 xIC2 1 xIC3 x 1IC4 0 yIC5 1 yIC6 y 0Fill in for MCU pin is 0Code:A1 A0IC1 0 0IC2 1 0IC3 0 1IC4 0 1IC5 1 1IC6 1 0You can only safely address IC1 and IC5.Fill in for MCU pin is 1Code:A1 A0IC1 0 1IC2 1 1IC3 1 1IC4 0 0IC5 1 0IC6 0 0Now you can only safely address IC1 and IC5.So this is even worse.Did not check the other possibilities because I don't see it work. If you think it will please provide your solution.

author: NiHaoMike
author_rank: Super Contributor
timestamp: March 20, 2024, 12:52:36 pm
content: If you do the bit banged I2C approach, you can have 2 or more data lines with a shared clock line, sending to multiple devices at the same time.

author: PCB.Wiz
author_rank: Super Contributor
timestamp: March 20, 2024, 06:36:02 pm
content: Quote from: pcprogrammer on March 20, 2024, 09:50:37 amThis is what I had in mind. All of a bank's active logic levels, map to the MCU pin.Bank 1 is active Pin = high, Bank 2 is active Pin = low.Code:Bank 1 Bank 200 BB0A B1A0 1BAA 11No Inverter means A==BA = 0 : All of bank1 parked at 00, Address 01,10,11 on bank 2A = 1 : All of bank2 parked at 11, Address 00,01,10 on bank 16 devices possible in total.The address range changes with A, but the MCU controls A so that's fine.If you also apply the reverse i2c pins idea, you can address 8 reversed, or 12 reversed + 1 pin.The OP just asked for 5.

author: GrantIsCoolAllegedly
author_rank: Newbie
timestamp: March 21, 2024, 02:26:53 am
content: Thanks a lot for the input, everyone. Some context is that I mostly work in the analogue domain, but am getting back into the headspace to resurrect a hybrid design that I got quite far with a few years ago but had to drop due to the chip shortage. So I'm slowly getting back into the headspace of using MCUs, switching from AVR to STM32 as I go.I've decided that given both the complication I initially described, and the requirement to effectively change all 5x4 digipot settings as fast as possible, 400KHz just won't cut it anyway. So perhaps it's best to put both the digipots and LCD on the SPI bus.