3. Data Transmission and Reception
SCI Initialization:
Before data can be transmitted or received, the SCI must be initialized
by software. To initialize the SCI, software must clear the TE and RE bits to 0, then execute
the following procedure.
(1) Set the desired communication format in the SMR.
(2) Write the value corresponding to the desired bit rate in the BRR. (This step is not
necessary if an external clock is used.)
(3) Select the clock and enable desired interrupts in the SCR.
(4) Set the TE and/or RE bit in the SCR to 1.
The TE and RE bits must both be cleared to 0 whenever the operating mode or data format is
changed.
After changing the operating mode or data format, before setting the TE and RE bits to 1
software must wait for at least the transfer time for 1 bit at the selected baud rate, to make sure
the SCI is initialized. If an external clock is used, the clock must not be stopped.
When clearing the TDRE bit during data transmission, to assure transfer of the correct data, do
not clear the TDRE bit until after writing data in the TDR. Similarly, in receiving data, do not
clear the RDRF bit until after reading data from the RDR.
Data Transmission:
The procedure for transmitting data is as follows.
(1) Set up the desired transmitting conditions in the SMR, SCR, and BRR.
(2) Set the TE bit in the SCR to 1.
The TXD pin will automatically be switched to output and one frame* of all 1’s will be
transmitted, after which the SCI is ready to transmit data.
(3) Check that the TDRE bit is set to 1, then write the first byte of transmit data in the TDR.
Next clear the TDRE bit to 0.
* A frame is the data for one character, including the start bit and stop bit(s).
273