Page 329 - ARM Based Microcontroller Projects Using MBED
P. 329
CHAPTER
12
SPI Bus Projects
12.1 OVERVIEW
In this chapter we shall be developing projects using the SPI (Serial Peripheral Interface)
bus with the Nucleo-F411RE development board.
TheSPIbusisoneofthecommonlyusedprotocolstoconnectsensorsandmanyotherdevices
to microcontrollers. The SPI bus is a master-slave-type bus protocol. In this protocol, one device
(themicrocontroller)isdesignatedasthemaster,andoneormoreotherdevices(usuallysensors)
aredesignatedasslaves.Inaminimumbusconfigurationthereisonemasterandonlyoneslave.
The master establishes communication with the slaves and controls all the activity on the bus.
Fig. 12.1 shows an SPI bus example with one master and three slaves. The SPI bus uses
three signals: clock (SCK), data in (SDI), and data out (SDO). The SDO of the master is
connected to the SDIs of the slaves, and SDOs of the slaves are connected to the SDI of the
master. The master generates the SCK signals to enable data to be transferred on the bus.
In every clock pulse 1 bit of data is moved from master to slave, or from slave to master.
The communication is only between a master and a slave, and the slaves cannot communicate
with each other. It is important to note that only one slave can be active at any time since there
CS CS CS
Microcontroller
Slave 1 Slave 2 Slave 3
SPI bus master
SCK
SDI
SDO
FIG. 12.1 SPI bus with one master and three slaves.
315
ARM-based Microcontroller Projects Using mbed # 2019 Elsevier Ltd. All rights reserved.
https://doi.org/10.1016/B978-0-08-102969-5.00012-4