Hardware manual

Rev. 3.0, 09/98, page 209 of 361
(3) Transmitting and Receiving Data
SCI Initialization: Before transmitting or receiving, software must clear the TE and RE bits
to “0” in the serial control register (SCR), then initialize the SCI as follows.
Note: When changing the communication mode or format, always clear the TE and RE bits to
“0” before following the procedure given below. Clearing TE to “0” sets TDRE to “1”
and initializes the transmit shift register (TSR). Clearing RE to “0,” however, does not
initialize the RDRF, PER, FER, and ORER flags and receive data register (RDR), which
retain their previous contents.
When an external clock is used, the clock should not be stopped during initialization or
subsequent operation. SCI operation becomes unreliable if the clock is stopped.
Clear TE and RE bits to
"0" in SCR
1 bit interval
elapsed?
Start transmitting or receiving
No
Yes
1. Select the communication format in the serial mode register (SMR).
2. Write the value corresponding to the bit rate in the bit rate register
(BRR). This step is not necessary when an external clock is used.
3. Select interrupts and the clock source in the serial control register
(SCR). Leave TE and RE cleared to "0." If clock output is selected,
in asynchronous mode, clock output starts immediately after the
setting is made in SCR.
4. Wait for at least the interval required to transmit or receive one bit,
then set TE or RE in the serial control register (SCR).
Setting TE or RE enables the SCI to use the TxD or RxD pin.
Also set the RIE, TIE, TEIE, and MPIE bits as necessary to enable
interrupts. The initial states are the mark transmit state, and the
idle receive state (waiting for a start bit).
Select communication
format in SMR
1
Set value in BRR
2
Set CKE1 and CKE0 bits in
SCR (leaving TE and RE
cleared to "0")
3
Set TE or RE to "1" in SCR,
and set RIE, TIE, TEIE, and
MPIE as necessary
4
Initialization
Figure 10.4 Sample Flowchart for SCI Initialization