[SOLVED]How many devices can be connected to the SPI bus

Thread Starter

Kittu20

Joined Oct 12, 2022
463
I am trying to understand how many I2C devices can be connected on one I2C bus for 8bit, 16bit 32bits microcontroller. how it decides how many devices can be connected.

I found that a total of 128 devices can be connected to the bus if the device address is 7 bits.

I understand that if we have an 8 bit microcontroller and I2C device whose address is 7 bits. We can connect 128 devices to the bus.

I want to understand more if there is 16bit and 32bit microcontroller. how many i2c devices of 7bit address can be connected to the bus ?

I think we can connect 128 devices even if the size of the micro controller is 16bit or 32 bit because 7 bits only give 128 addresses
 

Ian0

Joined Aug 7, 2020
9,677
I am trying to understand how many I2C devices can be connected on one I2C bus for 8bit, 16bit 32bits microcontroller. how it decides how many devices can be connected.

I found that a total of 128 devices can be connected to the bus if the device address is 7 bits.

I understand that if we have an 8 bit microcontroller and I2C device whose address is 7 bits. We can connect 128 devices to the bus.

I want to understand more if there is 16bit and 32bit microcontroller. how many i2c devices of 7bit address can be connected to the bus ?

I think we can connect 128 devices even if the size of the micro controller is 16bit or 32 bit because 7 bits only give 128 addresses
It is limited by capacitance, not by number of available addresses.

It is also an 8-bit system, so operating it with 16- or 32-bit microcontrollers doesn't make any difference.
 

Ian0

Joined Aug 7, 2020
9,677
do you mean logically it's possible but practically impossible to connect 128 devices?
Precisely. 400pF is the maximum.
A 24C1024 input is 8pF. That would allow 50 if there were no pcb track capacitance. It will probably mean that the maximum is around 32, just the same as it is for RS485 and CANbus.
The spec has a 10-bit addressing mode, so theoretically it is possible to address 1023 devices, but I've never seen it used.
The 1024th address is a general broadcast address that talks to everything on the bus (never seen that used either)
 

ronsimpson

Joined Oct 7, 2019
2,989
Many of the parts have an addressing system where only 4 or 8 of one type can be on the bus.
Example: I am using a memory chip that has an address of A0, A2, A4, A6, A8, AA, AC, or AE. There are 3 pins in the IC that set which of 8 addresses it will respond to. The IO part IC I am using only has 8 addresses reserved for it. (40 through 4E even numbers only)
 

Papabravo

Joined Feb 24, 2006
21,159
do you mean logically it's possible but practically impossible to connect 128 devices?
When you connect some number of devices, n, with an average impedance Zin to a bus they present n parallel loads of Zin to any driver. You must add to that whatever distributed capacitance in present on the PC board traces and you need to carefully select the pullup resistors on SCL and SDA. Too small and they draw excess current. Too large and you get sloppy rise and fall times.
 

dcbingaman

Joined Jun 30, 2021
1,065
If you cannot reduce the capacitance, the other option is to slow down the bus. I2C may be operated at slower speeds because it is a synchronous bus.
 

Thread Starter

Kittu20

Joined Oct 12, 2022
463
I have the same question for SPI devices. If we have 40 pins of microcontroller so how many SPI devices can be connected to single Bus?

I found that the CS pin is needed for each individual device to be identified.

How many SPI devices can I connect if I reserve three pins for ground, VCC and clock. so can we connect 37 SPI device to microcontroller?

I am asking both of question just for understand the basic concept
 

MrChips

Joined Oct 2, 2009
30,720
The same answer applies. You are limited by the total capacitance on the cabling.
If you slow down the clock you can connect a higher number of devices.
 

Ian0

Joined Aug 7, 2020
9,677
How do we identify which device to transfer data to when there are multiple SPI slave devices ?

i think we select the cs pin of the slave device to which we want to transfer the data
Correct. In theory, you can put as many devices on the bus as you have slave-select pins.
In practice it is limited by the capacitance. However, as it is not an open-drain structure using bi-directional communication, you can buffer the data and clock lines with something intended for bus driving - 74HC125 comes to mind.
 

WBahn

Joined Mar 31, 2012
29,979
@kittu You have essentially hijacked your own thread. You started out talking about I2C busses and then switched to SPI busses. Now you will be getting a mix of responses that may be impossible to distinguish which bus is being referred to. That's why it is best to adhere to the one-topic-per-thread rule.
 
Top