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).
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.
There are four associated pins for each SPI module, where x = 0,1,2
:
MISOx
).MOSIx
).SCKx
).$\\overline{\\textrm{SSx}}$
).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.
The SPI0 module uses the upper four Port S pins (PS4
- PS7
), where:
MISOx
pin uses pin 4 of Port S (PS4
). This pin is used to transmit data out of the SPI module when it is configured as a slave and receive data when it is configured as a master.MOSIx
pin uses pin 5 of Port S (PS5
). This pin is used to transmit data out of the SPI module when it is configured as a master and receive data when it is configured as a slave.SCK
uses pin 6 of Port S (PS6
). This pin is used to carry the clock signal that synchronizes SPI data transfer. It is an output if the SPI is configured as a master, but an input if the SPI is configured as a slave.$\\overline{\\textrm{SS}}$
pin uses pin 7 of Port S (PS7
). When configured as a slave, this pin must be grounded 0
for the SPI module to operate.The SPI1 uses the lower four Port S pins (PP0
- PP3
) and the SPI2 module uses the upper four Port S pins (PS4
- PS7
).