Serial Peripheral Interface (SPI)
MC68HC08AZ32A Data Sheet, Rev. 2
226
Freescale Semiconductor
Figure 16-11. SPRF/SPTE CPU Interrupt Timing
16.8 Resetting the SPI
Any system reset completely resets the SPI. Partial resets occur whenever the SPI enable bit (SPE) is
low. Whenever SPE is low, the following occurs:
The SPTE flag is set
Any transmission currently in progress is aborted
The shift register is cleared
The SPI state counter is cleared, making it ready for a new complete transmission
All the SPI port logic is defaulted back to being general purpose I/O.
The following items are reset only by a system reset:
All control bits in the SPCR register
All control bits in the SPSCR register (MODFEN, ERRIE, SPR1, and SPR0)
The status flags SPRF, OVRF, and MODF
By not resetting the control bits when SPE is low, the user can clear SPE between transmissions without
having to set all control bits again when SPE is set back high for the next transmission.
By not resetting the SPRF, OVRF, and MODF flags, the user can still service these interrupts after the
SPI has been disabled. The user can disable the SPI by writing 0 to the SPE bit. The SPI can also be
disabled by a mode fault occurring in an SPI that was configured as a master with the MODFEN bit set.
BIT
3
MOSI
SPSCK (CPHA:CPOL = 1:0)
SPTE
WRITE TO SPDR
1
PU WRITES BYTE 2 TO SPDR, QUEUEING
PU WRITES BYTE 1 TO SPDR, CLEARING
YTE 1 TRANSFERS FROM TRANSMIT DATA
2
3
5
PTE BIT.
EGISTER TO SHIFT REGISTER,
SPRF
READ SPSCR
MSB BIT
6
BIT
5
BIT
4
BIT
2
BIT
1
LSB MSB BIT
6
BIT
5
BIT
4
BIT
3
BIT
2
BIT
1
LSB MSB BIT
6
BYTE 2 TRANSFERS FROM TRANSMIT DATA
CPU WRITES BYTE 3 TO SPDR, QUEUEING
BYTE 3 TRANSFERS FROM TRANSMIT
5
8
10
8
10
RST INCOMING BYTE TRANSFERS FROM SHIFT
6
CPU READS SPSCR WITH SPRF BIT SET.
4
6
9
SECOND INCOMING BYTE TRANSFERS FROM
9
11
YTE 2 AND CLEARING SPTE BIT.
REGISTER TO SHIFT REGISTER, SETTING
HIFT REGISTER TO RECEIVE DATA REGISTER,
ETTING SPRF BIT.
BYTE 3 AND CLEARING SPTE BIT.
DATA REGISTER TO SHIFT REGISTER,
SHIFT REGISTER TO RECEIVE DATA REGISTER,
SETTING SPRF BIT.
12 CPU READS SPDR, CLEARING SPRF BIT.
BIT
5
BIT
4
BYTE 1
BYTE 2
BYTE 3
7
12
READ SPDR
7
CPU READS SPDR, CLEARING SPRF BIT.
11 CPU READS SPSCR WITH SPRF BIT SET.
ETTING SPTE BIT.
SETTING SPTE BIT.
SPTE BIT.