Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Example SCI Transmission - Lecture Notes | EMCH 367, Study notes of Mechanical Engineering

Material Type: Notes; Professor: Giurgiutiu; Class: MICROCNTROLLRS MECH ENGR; Subject: Mechanical Engineering; University: University of South Carolina - Columbia; Term: Fall 2009;

Typology: Study notes

Pre 2010

Uploaded on 10/01/2009

koofers-user-b9v
koofers-user-b9v 🇺🇸

5

(1)

10 documents

1 / 8

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
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
SWI
Initialize REGBAS in reg X
Initialize SCI:
BAUD = 9600
8-bit word
TE=1, RE=1
Load ‘T’ in accB
Check if TDRE is set
Load SCSR into accA
AND with mask %10000000
Loop if zero
Store AccB to SCDR
LABEL2
LABEL3
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
pf3
pf4
pf5
pf8

Partial preview of the text

Download Example SCI Transmission - Lecture Notes | EMCH 367 and more Study notes Mechanical Engineering in PDF only on Docsity!

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= 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

SWI

Initialize REGBAS in reg X Initialize SCI: BAUD = 9600 8 - bit word TE=1, RE= Load ‘T’ in accB Check if TDRE is set Load SCSR into accA AND with mask % Loop if zero Store AccB to SCDR

LABEL

LABEL

Code

START LDX #REGBAS

LDAA #%

STAA BAUD,X

LDAA #%

STAA SCCR1,X

LDAA #%

STAA SCCR2,X

LABEL2 LDAB #'T'

  • Send the character to the terminal LABEL3 LDAA SCSR,X ANDA #% BEQ LABEL
  • You are here when the transmission reg. is empty STAB SCDR,X BRA LABEL 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:

Note that the reset value of SCSR is %11000000, i.e., it has the flags TDRE and TC set. This indicates

that the transmitter is ready to transmit.

a) Press the RUN button. The program should loop on LABEL3 and exit the loop when the

condition TDRE=1 is satisfy. This condition is checked with the mask %10000000. The mask is

applied on the value found in SCSR. When bit 7 in SCSR is set, the mask senses it and the

condition for exiting the loop is satisfied. Since TDRE=1 from the reset, the loop is passed

through and exited.

Note that SCSR is %00000000. This proves that TDRE has been reset by the storing to SCDR. Also

note that the value $54 from accB has not yet arrived in SCDR. (The reason for this is that the simulator

has an internal delay when running SCI in manual mode.)

d) Press RUN again. The program loops several times on LABEL3 before exiting. While looping,

you can see SCSR=%00000000, i.e., TDRE=0. When exiting, SCSR=%10000000, i.e.,

TDRE=1. When the program pause, the screen looks like this:

Note that SCSR=%10000000, i.e., TDRE=1. The transmission of the character was done, and SCI

is ready to transmit again.

e) Press RUN again 2 times. Note that the character T has appeared in the serial receiver window.

Your screen capture looks like this:

f) Press RUN again. You get an additional character in the serial receiver window. Your screen

capture looks like this: