SERIAL COMMUNICATION INTERFACE (SCI)
6 - 48
PORT C
MOTOROLA
The interrupt service routine, which can be a fast interrupt or a long interrupt, (4) reads
the received character. Reading the SRX (5) automatically clears RDFR in the SSR and
makes the SRX ready to receive another byte.
If (1) an FE, PE, or OR occurs while receiving data (see Figure 6-24), (2) RDRF is set be-
cause a character has been received; FE, PE, or OR is set in the SSR to indicate that an
error was detected. Either (3) the SSR can be polled by software to look for errors, or (4)
interrupts can be used to execute an interrupt service routine. This interrupt is different
from the normal receive interrupt and is caused only by receive errors. The long interrupt
service routine should (5) read the SSR to determine what error was detected and then
(6) read the SRX to clear RDRF and all three error flags.
6.3.7.2
Asynchronous Data Transmission
Figure 6-25 illustrates initializing the SCI data transmitter for asynchronous data. The first
step (1) resets the SCI to prevent the SCI from transmitting or receiving data. Step two (2)
selects the desired operation by programming the SCR. As a minimum, the word format
(WDS2, WDS1, and WDS0) must be selected, and (3) the transmitter must be enabled
(TE=1). If (4) interrupts are to be used, set TIE equals one. Use Table 6-3 (a) through Ta-
ble 6-4 (b) to set (5) the baud rate (SCP and CD0–CD11 in the SCCR). Once the SCI is
completely configured, it can be enabled by (6) setting the TXD bit in the PCC. Transmis-
sion begins with (7) a preamble of ones.
If polling is used to transmit data (see Figure 6-26), the polling routine can look at either
TDRE or TRNE to determine when to load another byte into STX. If TDRE is used (1), one
byte may be loaded into STX. If TRNE is used (2), two bytes may be loaded into STX if
enough time is allowed for the first byte to begin transmission (see 6.3.2.4.2). If interrupts
are used (3), then an interrupt is generated when STX is empty. The interrupt routine,
which can be a fast interrupt or a long interrupt, writes (4) one byte into STX. If multidrop
mode is being used and this byte is an address, STXA should be used instead of STX.
Writing STX or STXA (5) clears TDRE in the SSR. When the transmit data shift register
is empty (6), the byte in STX (or STXA) is latched into the transmit data shift register,
TRNE is cleared, and TDRE is set.
There is a provision to send a break or preamble. A break (space) consists of a period of
zeros with no start or stop bits that is as long or longer than a character frame. A preamble
(mark) is an inverted break. A preamble of 10 or 11 ones (depending on the word length
selected by WDS2, WDS1, and WDS0) can be sent with the following procedure (see Fig-
ure 6-27). (1) Write the last byte to STX and (2) wait for TDRE equals one. This is the byte
that will be transmitted immediately before the preamble. (3) Clear TE and then again set
it to one. Momentarily clearing TE causes the output to go high for one character frame.
F
re
e
sc
a
le
S
e
m
ic
o
n
d
u
c
to
r,
I
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
n
c
.
..