
EMCH 367 Fundamentals of Microcontrollers Example SCI TRANSMISSION
EXAMPLE SCI TRANSMISSION
OBJECTIVE
This example has the following objectives:
Review the use of serial communication interface (SCI) for transmission
Illustrate the sending of a character through SCI
PROGRAM SCI_TRANSMIT
This program is an example of SCI transmission. The character T is being sent to SCDR when TDRE is
set.
Instructions
a) Load REGBAS
in reg. X
b) Initialize
BAUD=9600
c) Initialize 8-bit
word
d) Initialize TE and
RE
e) Load character
'T' in AccB
f) Check if TDRE
is set
g) Store accB to
SCDR
h) Branch back to
(v)
i) SWI
Flowchart
Initialize REGBAS in reg X
Initialize SCI:
BAUD = 9600
8-bit word
TE=1, RE=1
Check if TDRE is set
Load SCSR into accA
AND with mask %10000000
Loop if zero
Code
START LDX #REGBAS
LDAA #%00110000
STAA BAUD,X
LDAA #%00000000
STAA SCCR1,X
LDAA #%00001100
STAA SCCR2,X
LABEL2 LDAB #'T'
* Send the character to the terminal
LABEL3 LDAA SCSR,X
ANDA #%10000000
BEQ LABEL3
* You are here when the transmission reg. is
empty
STAB SCDR,X
BRA LABEL2
SWI
FLOWCHART AND CODE
The program flowchart is show to the right of the program instructions. Note the initialization block,
which contains reg. X initialization and SCI initialization. After initialization, the character T is loaded into
accB. Then, the status of TDRE (transmission data register empty) flag is checked in a loop. When
TDRE is found set, the loop is exited and the contents of accB is stored in SCDR (serial communication
data register). This operation automatically resets TDRE. Now, the program loops back to the beginning
and tries to send again.
The essential code for the program is shown to the right of the program flowchart. This essential code
was incorporated into the standard asm template to generate the file SCI_transmit.asm.
EXECUTION
Open THRSim11. Close the Commands window. View serial registers. View serial receiver. Open and
assemble SCI_transmit.asm. Set breakpoint at STAB SCDR,X instruction and at SWI. Reset registers.
Set standard labels (Label/Set Standard Labels). Set display of accA to binary. Set display of BAUD,
SCCR1, SCCR2, SCSR to binary. Arrange windows for maximum benefit: Reset, A, B, X. Press the
RESET button. Your screen should look like this:
Dr. Victor Giurgiutiu Page 111/28/2020