EasyManua.ls Logo

ST ST7 - Serial Peripheral Interface

ST ST7
317 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
125/317
5-Peripherals
5.7 SERIAL PERIPHERAL INTERFACE
The Serial Peripheral Interface is a device that allows synchronous, bit serial communication
between a microcontroller and a peripheral such as a serial-access memory, a Liquid Crystal
Display module, etc.; or between two or more microcontrollers. This interface only requires
three lines, thus saving pins for other purposes. The data is sent on a byte by byte basis. To
perform the same function using a byte-wide parallel interface, at least ten lines are needed:
eight for the data plus two for the handshake.
When connected to a peripheral, the SPI is configured as a master; when connected to an-
other microcontroller, it is configured either as a master or as a slave.
The maximum bit rate of a master is 4 MHz with a 16-MHz crystal, or 250 kBytes per second.
With this speed, serial transmission is just as fast as parallel transmission, since the instruc-
tions needed to put or get a byte through the channel take longer than the transmission.
Actually, transfer is bi-directional; at the same time that data is sent on one line, it is received
from the other line; this allows full-duplex transmission at the rate mentioned above when two
microcontrollers are connected together.
A supplementary pin, SS
, allows the SPI to be enabled when it is in slave mode. This allows
a master to be connected to several slaves and to communicate with only one slave at a time.
All the logic needed for multidrop communication is provided, including collision detection.
This permits reliable interprocessor communication. When the SPI is in master mode, this pin
must be set to a high level.
Here is an example of two microcontrollers connected together:
05-spi1
MOSI
MISO
MOSI
MISO
SCK
SCK
SS
SS
V
DD
permanent
MASTER
configuration
8-bit shift register
SPI Clock
generator
8-bit shift register
permanent
SLAVE
configuration
Simplest configuration for a dialogue with SPIs
between two microcontrollers
MSTR=1
MSTR=0

Table of Contents

Related product manuals