Understanding the Driving Capability of MCU’s SPI Interface and GPIO: How Many Slave Devices Can SPI Connect?

Friends involved in hardware design should be familiar with the SPI interface and the GPIO ports of MCUs, and many have personally designed SPI interfaces. When designing, did you consider this important parameter? — The driving capability of the SPI interface and ordinary GPIO ports. Today, let’s discuss how to evaluate the driving capability of SPI.When we design a master-slave SPI circuit (as shown in the figure below), have you ever thought about how many slave devices the MCU master can connect? Is it an unlimited number?Understanding the Driving Capability of MCU's SPI Interface and GPIO: How Many Slave Devices Can SPI Connect?The answer is certainly not; each master device requires a certain driving capability to drive the slave devices. When the load is too high, the driving capability may be insufficient. So how can we ensure that our design is sound? How do we consider the driving capability of SPI? Here, we will take the STM32 MCU as an example to see how much driving capability it has.Device driving capability: What we generally understand is the current driving capability of the device, which is the maximum current it can output.In the STM32 datasheet, we find this section on electrical characteristics 5. Electrical characteristics, and then locate the following image.Understanding the Driving Capability of MCU's SPI Interface and GPIO: How Many Slave Devices Can SPI Connect?Note: The section specifically discussing the SPI interface in the datasheet does not mention the current driving capability of the SPI interface because the SPI interfaces are push-pull outputs, consistent with ordinary IO ports. Therefore, the driving capability is uniformly explained in the position shown in the image above.From the information in the image above, we can see that the maximum sink/source current (pull current and sink current) can reach 8mA. Therefore, under normal circumstances, the driving capability of our GPIO ports is around 8mA. As long as we check the required current for driving the slave devices from their datasheets, we can calculate how many slave devices the MCU can support. If the driving current of the slave device is 2mA, then it can drive at least 4 slave devices without any issues.In the MCU’s datasheet, there is also a figure of 20mA. Those who are detail-oriented may have noticed this: sink or source up to 20mA (with a relaxed VOL/VOH). How should this be understood? After researching a lot of materials, I believe a reasonable explanation and translation is: under certain margins for VOL and VOH (output and input voltage), the pull current/sink current can even reach 20mA. What does this mean? Let’s look at this image to understand:Understanding the Driving Capability of MCU's SPI Interface and GPIO: How Many Slave Devices Can SPI Connect?When the COMS is conducting, there will be a conduction resistance Ron. The larger the current, the greater the voltage drop. Therefore, the high and low levels output by the GPIO port may experience a voltage drop, and the voltage range of VOL and VOH will change. As shown in the image, when the sink current is 20mA, the maximum value of the output low level may be 1.3V, which for many slave devices or other devices may be recognized as a high level, potentially leading to errors. This means that only when your connected device has a considerable receiving margin for this level can the GPIO port’s driving capability reach 20mA.Therefore, under normal circumstances, we use a driving current of 8mA and do not recommend overloading the IO ports and SPI interfaces.Now, let’s consider an extensibility issue: if the GPIO driving capability is insufficient and you still want to drive a large load or multiple loads, what should you do? It’s simple. If it’s a single ordinary IO port, you can increase the driving capability by adding an operational amplifier follower. If it’s an SPI interface, you need to connect a driver chip to drive other multiple slave devices, such as:74LV245.

Leave a Comment