Texas Instruments MSC1210 manual Reading the Serial Port

Models: MSC1210

1 324
Download 324 pages 20.97 Kb
Page 106
Image 106

Reading the Serial Port

9.5 Reading the Serial Port

Reading data received by the serial port is equally easy. To read a byte from the serial port, just read the value stored in the SBUF0 (99H) SFR after the MSC1210 has automatically set the RI flag in SCON.

For example, if you want the program to wait for a character to be received and subsequently read it into the accumulator, the following code segment can be used:

JNB

RI,$

;Wait

for

the MSC1210 to

set

the RI

flag

MOV

A,SBUF

;Read

the

character from

the

serial

port

The first line of the above code segment waits for the MSC1210 to set the RI flag; again, the MSC1210 sets the RI flag automatically when it receives a character via the serial port. So as long as the bit is not set, the program re- peats the JNB instruction continuously.

Once a character is received, the RI bit will be set automatically, the previous condition automatically fails, and program flow falls through to the MOV instruction that reads the character into the accumulator.

9-16

Page 106
Image 106
Texas Instruments MSC1210 manual Reading the Serial Port