
Serial Peripheral Interface (SPI) Module
MC68HC08GR32A MC68HC08GR16A Data Sheet, Rev. 0
192
Freescale Semiconductor
If the CPU SPRF interrupt is enabled and the OVRF interrupt is not, watch for an overflow condition.
possible to read the SPSCR and SPDR to clear the SPRF without problems. However, as illustrated by
the second transmission example, the OVRF bit can be set in between the time that SPSCR and SPDR
are read.
Figure 15-10. Missed Read of Overflow Condition
In this case, an overflow can be missed easily. Since no more SPRF interrupts can be generated until this
OVRF is serviced, it is not obvious that bytes are being lost as more transmissions are completed. To
prevent this, either enable the OVRF interrupt or do another read of the SPSCR following the read of the
SPDR. This ensures that the OVRF was not set before the SPRF was cleared and that future
transmissions can set the SPRF bit.
Figure 15-11 illustrates this process. Generally, to avoid this second
SPSCR read, enable the OVRF to the CPU by setting the ERRIE bit.
Figure 15-11. Clearing SPRF When OVRF Interrupt Is Not Enabled
READ
OVRF
SPRF
BYTE 1
BYTE 2
BYTE 3
BYTE 4
BYTE 1 SETS SPRF BIT.
READ SPSCR WITH SPRF BIT SET
READ BYTE 1 IN SPDR,
BYTE 2 SETS SPRF BIT.
READ SPSCR WITH SPRF BIT SET
BYTE 3 SETS OVRF BIT. BYTE 3 IS LOST.
READ BYTE 2 IN SPDR, CLEARING SPRF BIT,
BYTE 4 FAILS TO SET SPRF BIT BECAUSE
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
CLEARING SPRF BIT.
BUT NOT OVRF BIT.
OVRF BIT IS NOT CLEARED. BYTE 4 IS LOST.
AND OVRF BIT CLEAR.
SPSCR
SPDR
READ
OVRF
SPRF
BYTE 1
BYTE 2
BYTE 3
BYTE 4
1
BYTE 1 SETS SPRF BIT.
READ SPSCR WITH SPRF BIT SET
READ BYTE 1 IN SPDR,
READ SPSCR AGAIN
BYTE 2 SETS SPRF BIT.
READ SPSCR WITH SPRF BIT SET
BYTE 3 SETS OVRF BIT. BYTE 3 IS LOST.
READ BYTE 2 SPDR, CLEARING OVRF BIT.
BYTE 4 SETS SPRF BIT.
READ SPSCR.
READ BYTE 4 IN SPDR, CLEARING SPRF BIT.
READ SPSCR AGAIN TO CHECK OVRF BIT.
1
2
3
CLEARING SPRF BIT.
4
TO CHECK OVRF BIT.
5
6
7
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
SPI RECEIVE
COMPLETE
AND OVRF BIT CLEAR.
SPSCR
SPDR
READ BYTE 2 IN SPDR, CLEARING SPRF BIT.
8
READ SPSCR AGAIN TO CHECK OVRF BIT.
9