Functional Description and Application Information
Serial Peripheral Interface (S12SPIV4)
MM912F634
Freescale Semiconductor
321
4.38.3.2.5
SPI Data Register (SPIDR)
Read: Anytime; normally read only when SPIF is set
Write: Anytime
The SPI data register is both the input and output register for SPI data. A write to this register allows a data byte to be
queued and transmitted. For an SPI configured as a master, a queued data byte is transmitted immediately after the
previous transmission has completed. The SPI transmitter empty flag SPTEF in the SPISR register indicates when the
SPI data register is ready to accept new data.
Received data in the SPIDR is valid when SPIF is set.
If SPIF is cleared and a byte has been received, the received byte is transferred from the receive shift register to the
SPIDR and SPIF is set.
If SPIF is set and not serviced, and a second byte has been received, the second received byte is kept as valid byte in
the receive shift register until the start of another transmission. The byte in the SPIDR does not change.
If SPIF is set and a valid byte is in the receive shift register, and SPIF is serviced before the start of a third transmission,
the byte in the receive shift register is transferred into the SPIDR and SPIF remains set (see
Figure 100).If SPIF is set and a valid byte is in the receive shift register, and SPIF is serviced after the start of a third transmission,
the byte in the receive shift register has become invalid and is not transferred into the SPIDR (see
Figure 101).
Table 413. SPISR Field Descriptions
Field
Description
7
SPIF
SPIF Interrupt Flag — This bit is set after a received data byte has been transferred into the SPI data register. This bit is
cleared by reading the SPISR register (with SPIF set) followed by a read access to the SPI data register.
0 Transfer not yet complete.
1 New data copied to SPIDR.
5
SPTEF
SPI Transmit Empty Interrupt Flag — If set, this bit indicates that the transmit data register is empty. To clear this bit and
place data into the transmit data register, SPISR must be read with SPTEF = 1, followed by a write to SPIDR. Any write to the
SPI data register without reading SPTEF = 1, is effectively ignored.
0 SPI data register not empty.
1 SPI data register empty.
4
MODF
Mode Fault Flag — This bit is set if the SS input becomes low, while the SPI is configured as a master and mode fault detection
Register 2 (SPICR2)"”. The flag is cleared automatically by a read of the SPI status register (with MODF set) followed by a write to the SPI control register 1.
0 Mode fault has not occurred.
1 Mode fault has occurred.
Table 414. SPI Data Register (SPIDR)
0x00ED
7
6
5
432
10
R
Bit 7
6
543
22
Bit 0
W
Reset
0
000
00
0