On I2C buses you can hock up 112 devices. So why do so many microcontrollers have up to four I2C ports, when you could just operate enough devices for most applications on one I2C interface?
Asked
Active
Viewed 328 times
3
-
Sometimes I2C devices have a limited number of addresses. If you want to use 4 temperature sensors and they are only available with 2 different I2C addresses, having multiple busses is one way to use the additional sensors. – John D Aug 12 '18 at 16:05
-
The problem is not that "sometimes" there is a limited number of addresses, the number of addresses is 127. The problem is that these addresses are hard-coded into very narrow ranges, and the I2C protocol doesn't have a mechanism for flexible assignment of arbitrary addresses, unlike the enumeration process in USB. – Ale..chenski Aug 12 '18 at 21:44
1 Answers
5
As @JohnD says, you may need to talk to several devices which have the same built-in, unchangeable address.
Another reason for multiple I2C busses is that they can be very slow. Standard I2C devices only run at 100 kHz. By having multiple busses you can access multiple devices in parallel, effectively increasing the data rate.
A third possibility is that you want your MCU to act as a slave on one bus and a master on another.
Michael Karas
- 57,328
- 3
- 71
- 138
Elliot Alderson
- 31,521
- 5
- 30
- 67
-
4Fourth possibility: One of the interfaces is on pins multiplexed with functions you want to use, and the other interface is on pins multiplexed with functions another customer might want to use. – The Photon Aug 12 '18 at 17:09
-
1Fifth possibility: You have multiple instances of a hardware module that supports multiple protocols (e.g., UART, SPI, and I²C), and it would not be worth the extra effort to remove I²C. – CL. Aug 12 '18 at 17:52
-
1@ThePhoton Thanks for your addition. I haven't run in to that problem myself but I can see it happening. – Elliot Alderson Aug 12 '18 at 18:38
-
1@CL. Good point...the serial interfaces are tiny and it's easier just to make them all alike. – Elliot Alderson Aug 12 '18 at 18:39
-
3Sixth possibility: most i2c devices dont play nice with the bus when they are not powered. Having multiple buses allows to do power-gating on different board subsystems. – Nipo Aug 12 '18 at 19:57
-
2One more: hot-plugging I2C slave devices (example, hot-swap power supplies). Pulling one while another slave is communicating may glitch the bus. Much easier to handle if each is on a separate bus. – DoxyLover Aug 12 '18 at 20:26
-
Eighth: Each I²C driver can only drive so much capacitive loading on the bus. Two buses, two drivers: twice the drive. – Marcus Müller Aug 12 '18 at 22:38