cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple I2C Slave Addresses (more than 2)

JKing.3
Associate II

Is there a way to handle a lot of discrete I2C slave addresses; I can't cover all the different addresses I need with the standard two addresses + masks without covering unwanted ones that I don't want to be ACK'd.

I'm wondering if there's a way the code can determine the ACK response after seeing the address match irq. I can't really see if this is possible from the reference manual.

Any thoughts appreciated.

Thanks

2 REPLIES 2
Danish1
Lead II

I don't think the ST I2C hardware allows you to respond on more than two slave addresses.

You could wire the I2C lines to multiple I2C peripherals if your stm32 has more than one, but this does not "scale" well.

ST have a number of examples of doing serial communications in software using timers and DMA to clock bits in or out, so that's UART TX, UART RX, SPI TX, I2C Master.

I think the right thing is to do the I2C slave in interrupt-driven software. I2C is slow, normally maxing out at 400 kHz (exceptionally 1 MHz).

So there's sufficient time in an interrupt from an SCL edge to identify the state of SCL, and if appropriate clock in / out the SDA line.

And once the last bit of the address byte is received, to look up in a table whether this is one you want to ACK or not.

I won't pretend that this will be easy to do. But it sounds like an interesting sub-project.

Regards,

Danish

JKing.3
Associate II

Thanks for your reply.

Yes I think the bit-bashed route will be the way to go. I'm using the other I2C interfaces for other devices that can't be on the same bus.

Regards

Julian