46.7.8 SPI Mode
The Serial Peripheral Interface (SPI) mode is a synchronous serial data link that provides communication with external devices in Host or Client mode. It also enables communication between processors if an external processor is connected to the system.
The Serial Peripheral Interface is essentially a shift register that serially transmits data bits to other SPIs. During a data transfer, one SPI system acts as the “host” which controls the data flow, while the other devices act as “clients'' which have data shifted into and out by the host. Different CPUs can take turns being hosts and one host may simultaneously shift data into multiple clients. (Multiple host protocol is the opposite of single host protocol, where one CPU is always the host while all of the others are always clients.) However, only one client may drive its output to write data back to the host at any given time.
A client device is selected when its NSS signal is asserted by the host. The USART in SPI Host mode can address only one SPI client because it can generate only one NSS signal.
The SPI system consists of two data lines and two control lines:
- Host Out Client In (MOSI): This data line supplies the output data from the host shifted into the input of the client.
- Host In Client Out (MISO): This data line supplies the output data from a client to the input of the host.
- Serial Clock (SCK): This control line is driven by the host and regulates the flow of the data bits. The host may transmit data at a variety of bit rates. The SCK line cycles once for each bit that is transmitted.
- Client Select (NSS): This control line allows the host to select or deselect the client.