Hardware Reference
In-Depth Information
To transfer data to one or more SPI slaves, the MCU writes data into the SPI data register,
and eight clock pulses are generated to shift out the data in the SPI data register from the MOSI
pin. If the MISO pin of the MCU is also connected (to the slave), then 8 data bits are also shifted
into the SPI data register. To read data from the slave, the MCU also needs to write data into
the SPI data register to trigger clock pulses to be sent out from the SCK pin. However, the value
written into the SPI data register is unimportant in this case.
When configured as a slave device, the HCS12 MCU also needs the fourth signal called
Slave Select (SS). The SS signal enables the HCS12 slave to respond to an SPI data transfer. Most
slave peripheral devices have signals called CE (chip enable) or CS (chip select) to enable/disable
the SPI data transfer.
Multiple peripheral devices with an SPI interface can be interfaced with a single MCU
simultaneously. There are many different methods for interfacing multiple peripheral devices
(with SPI interface) to the MCU. Two popular connection methods are
1. Parallel connection . In this method, the MISO, MOSI, and SCK signals of all the
peripheral devices are connected to the same signals of the HCS12 device. The
HCS12 MCU also needs to use certain unused I/O pins to control the CS (or CE)
inputs of each individual peripheral device. Using this method, the HCS12 MCU can
exchange data with any selected peripheral device without affecting other peripheral
devices.
2. Serial connection . In this method, the MOSI input of a peripheral device is
connected to the MISO pin of its predecessor, and the MISO output of a peripheral
device is connected to the MOSI input of its successor. The MOSI input of the
peripheral device that is closest (in terms of connection) to the MCU is connected
to the MOSI output of the MCU. The MISO output of the last peripheral device
(in the loop) is connected to the MISO input of the MCU. The SCK inputs of all
peripheral devices are tied to the SCK pin of the MCU. Using this method, the data
to be sent to the last device in the loop will need to go through all other peripheral
devices. The CE (or CS) signals of all peripheral devices are controlled by the same
signal.
In all of the peripheral devices with the SPI interface, shift registers such as 74HC595 and
74HC589 can be used to add parallel output and input ports to the MCU. The widely used digi-
tal temperature sensors are quite useful for displaying the ambient temperature. The TC72 and
TC77 from Microchip and LM74 from National Semiconductor are digital temperature sensors
with the SPI interface. The SPI interface is also often added to LED and LCD display drivers.
The MAX7221 from Dallas-Maxim can drive up to eight seven-segment displays. The MC14489
from Freescale can drive up to five seven-segment displays. Both driver chips can be cascaded to
drive more displays. Many A/D and D/A converters also have an SPI interface, for example, the
12-bit D/A converter MCP4922. Matrix displays have been widely used in recent years. They
use the time-multiplexing method to display multiple digits. Due to their high demand on CPU
time in performing time multiplexing, driver chips such as MAX6952 and MAX6953 have been
designed to off-load the CPU from time-multiplexing matrix displays.
10.14 Exercises
E10.1 Confi gure the SPI0 module to operate with the following setting:
Master mode with all interrupt enabled
SCK0 idle high and data shifted on the falling edge
 
Search WWH ::




Custom Search