SERIAL COMMUNICATION INTERFACE (SCI)
6 - 68
PORT C
MOTOROLA
6.3.9
SCI Timer
The SCI clock determines the data transmission rate and can also be used to establish a periodic
interrupt that can act as an event timer or be used in any other timing function. Figure 6-35 illus-
trates how the SCI timer is programmed. Bits CD11–CD0, SCP, and STIR in the SCCR work to-
gether to determine the time base. The crystal oscillator f
osc
is first divided by 2 and then divided
by the number CD11–CD0 in the SCCR. The oscillator is then divided by 1 (if SCP=0) or eight
(if SCP=1). This output is used as is if STIR = 1 or, if STIR = 0, it is divided by 2 and then by 16
before being used. If TMIE in the SCR = 1 when the periodic timeout occurs, the SCI timer inter-
rupt is recognized and pending. The SCI timer interrupt is automatically cleared when the inter-
rupt is serviced. This interrupt will occur every time the periodic timer times out. If only the timer
function is being used (i.e., PC0, PC1, and PC2 pins have been programmed as GPIO pins), the
transmit interrupts should be turned off (TIE=0). Under individual reset, TDRE will remain set and
the timer will continuously generate interrupts.
Figure 6-35 shows that an external clock can be used for SCI receive and/or transmit, which
frees the SCI timer to be programmed for a different interrupt rate. In addition, both the SCI timer
interrupt and the SCI can use the internal time base if the SCI receiver and/or transmitter require
the same clock period as the SCI timer.
The program in Figure 6-36 configures the SCI to interrupt the DSP at fixed intervals. The pro-
gram starts by setting equates for convenience and clarity and then points the reset vector to the
start of the program. The SCI timer interrupt vector location contains “move (R0)+”, incrementing
the contents of R0, which serves as an elapsed time counter.
The timer initialization consists of enabling the SCI timer interrupt, setting the SCI baud rate
counters for the desired interrupt rate, setting the interrupt mask, enabling the interrupt, and then
enabling the SCI state machine.
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
.
..