Skip to main content
JKing.3
Associate II
July 18, 2019
Question

Multiple I2C Slave Addresses (more than 2)

  • July 18, 2019
  • 2 replies
  • 1513 views

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

This topic has been closed for replies.

2 replies

Danish1
Lead III
July 18, 2019

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
JKing.3Author
Associate II
August 6, 2019

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