Datasheet

Functional Description
MC68HC908QB8 Data Sheet, Rev. 3
Freescale Semiconductor 165
In this case, an overflow can be missed easily. Because 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-10 illustrates this process. Generally, to avoid this second
SPSCR read, enable OVRF by setting the ERRIE bit.
Figure 15-9. Missed Read of Overflow Condition
Figure 15-10. Clearing SPRF When OVRF Interrupt Is Not Enabled
READ
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
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.
AND OVRF BIT CLEAR.
SPSCR
SPDR
READ
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 IN SPDR,
READ SPSCR AGAIN
READ BYTE 2 SPDR,
BYTE 4 SETS SPRF BIT.
READ SPSCR.
READ BYTE 4 IN SPDR,
READ SPSCR AGAIN
1
2
3
CLEARING SPRF BIT.
4
TO CHECK OVRF BIT.
5
6
7
8
9
CLEARING SPRF BIT.
TO CHECK OVRF BIT.
10
CLEARING OVRF BIT.
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
CLEARING SPRF BIT.
TO CHECK OVRF BIT.
SPI RECEIVE
COMPLETE
AND OVRF BIT CLEAR. AND OVRF BIT CLEAR.
SPSCR
SPDR