Texas Instruments MSC1210 Power Supply User Manual


 
Reading the Serial Port
9-16
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 (99
H
) 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.