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 Reception - 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: Unknown 1989;

Typology: Study notes

Pre 2010

Uploaded on 10/01/2009

koofers-user-x68-1
koofers-user-x68-1 🇺🇸

10 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
EMCH 367 Fundamentals of Microcontrollers Example SCI RECEPTION
EXAMPLE SCI RECEPTION
OBJECTIVE
This example has the following objectives:
Review the use of serial communication interface (SCI) for reception
Illustrate the receiving of a character through SCI
PROGRAM SCI_RECEPT
This program is an example of SCI reception. 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
Wait for the reception of a keystroke
e) check if RDRF is set by
loading SCSR into accA and
AND with mask for RDRF,
%00100000
You are here when reception data reg. is full
f) Load SCDR into accB
g) Store accB through Port B
h) Branch back to (e)
i) SWI
Flowchart
SWI
Initialize REGBAS in reg X
Initialize SCI:
BAUD = 9600
8-bit word
TE=1, RE=1
No operation
Check if RDRF is set
Load SCSR into accA
AND with mask %00100000
Loop if zero
Load accB from SCDR
Store accB to Port B
LABEL0
LABEL1
Code
START LDX #REGBAS
LDAA #%00110000
STAA BAUD,X
LDAA #%00000000
STAA SCCR1,X
LDAA #%00001100
STAA SCCR2,X
LABEL0 NOP
LABEL1 LDAA SCSR,X
ANDA #%00100000
BEQ LABEL1
LDAB SCDR,X
STAB PORTB,X
BRA LABEL0
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 status of RDRF
(reception data register full) flag is checked in a loop. When RDRF is set, the loop is exited and the
content of SCDR (serial communication data register) is loaded in accB. This operation automatically
resets RDRF. Now, the program loops back to the beginning and waits for another transmission.
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_recept.asm.
EXECUTION
Open THRSim11. Close the Commands window. View ports registers and serial registers. View serial
transmitter. Open and assemble SCI_recept.asm. Set breakpoint at LDAB SCDR,X and at SWI. Reset
registers. Set standard labels (Label/Set Standard Labels). Set display of BAUD, SCCR1, SCCR2,
SCSR to binary. Set display of accA to binary. Arrange windows for maximum benefit: Reset, A, B, X,
PORTB. Press the RESET button. Your screen should look like this:
Dr. Victor Giurgiutiu Page 111/29/2020
pf3
pf4
pf5

Partial preview of the text

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

EXAMPLE SCI RECEPTION

OBJECTIVE

This example has the following objectives:

 Review the use of serial communication interface (SCI) for reception

 Illustrate the receiving of a character through SCI

PROGRAM SCI_RECEPT

This program is an example of SCI reception. 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 Wait for the reception of a keystroke e) check if RDRF is set by loading SCSR into accA and AND with mask for RDRF, % You are here when reception data reg. is full f) Load SCDR into accB g) Store accB through Port B h) Branch back to (e) i) SWI

Flowchart

SWI

Initialize REGBAS in reg X

Initialize SCI:

BAUD = 9600

8 - bit word

TE=1, RE=

No operation

Check if RDRF is set

Load SCSR into accA

AND with mask %

Loop if zero

Load accB from SCDR

Store accB to Port B

LABEL

LABEL

Code

START LDX #REGBAS

LDAA #%

STAA BAUD,X

LDAA #%

STAA SCCR1,X

LDAA #%

STAA SCCR2,X

LABEL0 NOP

LABEL1 LDAA SCSR,X

ANDA #%

BEQ LABEL

LDAB SCDR,X

STAB PORTB,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 status of RDRF

(reception data register full) flag is checked in a loop. When RDRF is set, the loop is exited and the

content of SCDR (serial communication data register) is loaded in accB. This operation automatically

resets RDRF. Now, the program loops back to the beginning and waits for another transmission.

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_recept.asm.

EXECUTION

Open THRSim11. Close the Commands window. View ports registers and serial registers. View serial

transmitter. Open and assemble SCI_recept.asm. Set breakpoint at LDAB SCDR,X and at SWI. Reset

registers. Set standard labels (Label/Set Standard Labels). Set display of BAUD, SCCR1, SCCR2,

SCSR to binary. Set display of accA to binary. Arrange windows for maximum benefit: Reset, A, B, X,

PORTB. Press the RESET button. Your screen should look like this:

a) Press the RUN button. The program should loop on LABEL1 and exit the loop when the condition RDRF=1 is satisfy. This condition is checked with the mask %00100000. The mask is applied on the value found in SCSR. When bit 5 in SCSR is set, the mask senses it and the condition for exiting the loop is satisfied. b) Type the character T in the serial transmitter window and press Send. The character is sent to the MCU. The MCU takes a few laps to sense it. When the MCU senses it, the RDRF gets set, and the ‘check RDRF’ loop is exited. c) When the ‘check RDRF’ loop is exited, the program gets to the line LDAB SCDR,X This line is a breakpoint. At this moment, the screen looks like this:

e) Step again. The content of accB is stored in PORTB. Your screen looks like this: Note that the ASCII code for T, i.e., $54, appears in PORTB. f) Switch again to auto run. The program loops now again on LABEL1. Press again the send button in the serial transmitter. The character T is sent again, and after a few laps the program exits the loop and gets to the LDAB SCDR,X breakpoint. g) Run again automatically. Change the character in the serial transmitter to A. You will notice that the corresponding ASCII code, $41, appear in SCDR, and then, after manual steps, gets loaded in accB and stored in PORTB. WHAT YOU HAVE LEARNED In this example, you have learned:  The use of serial communication interface (SCI) for reception  The reception of a character through SCI  New words and notations: RDRF, ASCII code.

EMCH 367 Fundamentals of Microcontrollers qkd4cw-818910-3288344-o-20example-sci-recept- doc.doc