mc68hc908qb4 Freescale Semiconductor, Inc, mc68hc908qb4 Datasheet - Page 165

no-image

mc68hc908qb4

Manufacturer Part Number
mc68hc908qb4
Description
M68hc08 Microcontrollers
Manufacturer
Freescale Semiconductor, Inc
Datasheet
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.
SPSCR read, enable OVRF by setting the ERRIE bit.
Freescale Semiconductor
1
2
3
4
SPI RECEIVE
SPSCR
COMPLETE
OVRF
READ
READ
SPDR
SPRF
BYTE 1 SETS SPRF BIT.
READ SPSCR WITH SPRF BIT SET
AND OVRF BIT CLEAR.
READ BYTE 1 IN SPDR,
CLEARING SPRF BIT.
READ SPSCR AGAIN
TO CHECK OVRF BIT.
SPSCR
Figure 15-10. Clearing SPRF When OVRF Interrupt Is Not Enabled
OVRF
READ
READ
SPDR
SPRF
1
2
3
4
BYTE 1
BYTE 1 SETS SPRF BIT.
READ SPSCR WITH SPRF BIT SET
AND OVRF BIT CLEAR.
READ BYTE 1 IN SPDR,
CLEARING SPRF BIT.
BYTE 2 SETS SPRF BIT.
BYTE 1
1
1
2
Figure 15-9. Missed Read of Overflow Condition
2
3
3
Figure 15-10
MC68HC908QB8 Data Sheet, Rev. 2
4
BYTE 2
BYTE 2
5
6
7
8
9
4
READ SPSCR AGAIN
TO CHECK OVRF BIT.
5
BYTE 2 SETS SPRF BIT.
READ SPSCR WITH SPRF BIT SET
AND OVRF BIT CLEAR.
BYTE 3 SETS OVRF BIT. BYTE 3 IS LOST.
READ BYTE 2 IN SPDR,
CLEARING SPRF BIT.
illustrates this process. Generally, to avoid this second
BYTE 3
BYTE 3
6
5
5
6
7
8
7
6
READ SPSCR WITH SPRF BIT SET
AND OVRF BIT CLEAR.
BYTE 3 SETS OVRF BIT. BYTE 3 IS LOST.
READ BYTE 2 IN SPDR, CLEARING SPRF BIT,
BUT NOT OVRF BIT.
BYTE 4 FAILS TO SET SPRF BIT BECAUSE
OVRF BIT IS NOT CLEARED. BYTE 4 IS LOST.
8
7
9
BYTE 4
BYTE 4
10
11
8
12
10
11
12
13
14
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.
13
Functional Description
14
165

Related parts for mc68hc908qb4