402
Start transmitting and receiving
Initialization
Read TDRE bit in SSR
Total
count transmitted and
received?
Transmitting/receiving ends
(1)
(2)
No
Yes
TDRE = 1?
Write transmit data to TDR
and clear TDRE bit in
SSR to 0
RDRF = 1?
No
Yes
Yes
No
Read ORER bit in SSR
Error handling
(3)
ORER = 1?
No
Read RDRF bit in SSR
(5)
Yes
(4)
Read receive data in
RDR and clear RDRF bit
in SSR to 0
Clear TE and RE bits in
SCR to 0
Note: When switching from transmitting or receiving to simultaneous transmitting and
receiving, clear both the TE bit and the RE bit to 0, then set both this to 1
simultaneously.
Figure 13.20 Sample Flowchart for Serial Transmitting and Receiving