One STM32 I2C controller with multiple I2C STM32 slaves #13705
-
|
I was looking for a robust implementation of one controller, multiple slaves I2C setup on a stm32f411 and came across @peterhinch's wonderful library for handling this in an async context. I tested it on one master with one slave (both stm32f411) and it worked fine. Now I was wondering if this can be used with multiple slaves with no additional latency (since there still is a blocking portion)? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 7 replies
-
|
I think this would be difficult. If you look at the design section of the docs the initialisation code would need to be adapted. A bigger difficulty is synchronisation. Counter-intuitively transfers are initiated by the I2C slave. The challenge would be to ensure that multiple slaves do not attempt to do this concurrently. |
Beta Was this translation helpful? Give feedback.
-
|
Another communications option is syncom. This is point to point, but you could have multiple link instances on one platform. It is asynchronous, full duplex and cross platform. It can optionally detect an outage in an endpoint and issue a hardware reset. It does have some significant drawbacks. It uses bit banging so is slow, and each link uses four GPIO lines. |
Beta Was this translation helpful? Give feedback.
-
|
I think you'd run out of GPIO pins (4*32=128). On further thought multi-drop I2C might be possible if there were only one There are a couple of issues with 32 responders: each requires 2 GPIO lines plus the two for the bus - 66 GPIOs! Secondly there may be electrical issues with an I2C bus having so many nodes. You might need strong pullups and possibly a low clock rate to deal with capacitance. I have no experience with that many nodes: perhaps someone else can advise. You might want to consider CAN bus which is a proper multi-master bus on two wires. I have no experience of this - it seems only to be supported on STM but if this looks like it could meet your needs a specific query might raise some knowledgeable responses. |
Beta Was this translation helpful? Give feedback.
-
|
What this seems to suggest is that You could test this theory by starting the following in another thread: def test_function():
while True:
print("Test")
time.sleep_ms(250)If this fails to run concurrently then the above theory looks correct. |
Beta Was this translation helpful? Give feedback.
I think this would be difficult. If you look at the design section of the docs the initialisation code would need to be adapted. A bigger difficulty is synchronisation. Counter-intuitively transfers are initiated by the I2C slave. The challenge would be to ensure that multiple slaves do not attempt to do this concurrently.