10.2 Introduction to the SPI Function

The serial peripheral interface (SPI) a 4-wire serial bus that allows the HCS12 to communicate synchronously with peripheral devices and other microcontrollers. An HCS12 device may have from one to three identical SPI modules (SPI0, SPI1, and SPI2).

SPI Module

The SPI must be enabled to operate. Each SPI module can operate as a master or as a slave. The figure below depicts two SPI modules, one acting as a master and the other as a slave.

Figure 10.1 Two SPI Modules: Master and slave.

Figure 10.1 Two SPI Modules: Master and slave.

There are four associated pins for each SPI module, where x = 0,1,2:

Each SPI module has an 8-bit shift register as shown in the figure above. In a master-slave configuration, the two shift registers can be viewed as one 16-bit shift register connected by the MISO and MOSI signals.

SPI Signal Pins

The SPI0 module uses the upper four Port S pins (PS4 - PS7), where:

The SPI1 uses the lower four Port S pins (PP0 - PP3) and the SPI2 module uses the upper four Port S pins (PS4 - PS7).