4 writing to the serial port, Table 9−6. baud rate settings for timer 2 – Texas Instruments MSC1210 User Manual

Page 105

Advertising
background image

Writing to the Serial Port

9-15

Serial Communication

Table 9−6. Baud Rate Settings for Timer 2.

Baud Rate

33MHz clk

25MHz clk

11.0592MHz clk

Baud Rate

(kb/s)

C/T2

RCAP2H

RCAP2L

RCAP2H

RCAP2L

RCAP2H

RCAP2L

19.2

0

FF

H

EE

H

FF

H

F2

H

FF

H

FA

H

9.6

0

FF

H

CA

H

FF

H

D7

H

FF

H

EE

H

4.8

0

FF

H

95

H

FF

H

AF

H

FF

H

DC

H

2.4

0

FF

H

29

H

FF

H

5D

H

FF

H

B8

H

1.2

0

FE

H

52

H

FE

H

BB

H

FF

H

70

H

1.2

0

FC

H

A5

H

FD

H

75

H

FE

H

E0

H

9.4

Writing to the Serial Port

Once the serial port has been properly configured as explained previously, the
serial port is ready to be used to send and receive data. If you think configuring
the serial port was easy, using the serial port will be even easier.

To write a byte to the serial port, simply write the value to the SBUF0 (99

H

)

SFR. For example, sending the letter A to the serial port is accomplished as
easily as:

MOV SBUF0,#’A’

Upon execution of the above instruction, the MSC1210 will begin transmitting
the character via the serial port. Obviously, transmission is not instanta-
neous—it takes a measurable amount of time to transmit the eight data bits
that make up the byte, along with its start and stop bits—and because the
MSC1210 does not have a serial output buffer, you need to be sure that a char-
acter is completely transmitted before trying to transmit the next character.

The MSC1210 lets you know when it is done transmitting a character by setting
the TI bit in SCON. When this bit is set, the last character has been transmitted and
the next character, if any, may be sent. Consider the following code segment:

CLR TI

;Be sure the bit is initially clear

MOV SBUF,#’A’

;Send the letter ‘A’ to the serial port

JNB TI,$

;Pause until the RI bit is set.

The above three instructions transmit a character and wait for the TI bit to be
set before continuing. The last instruction says jump if the TI bit is not set to
$. The $ character (in most assemblers), means the same address of the cur-
rent instruction. Therefore, the MSC1210 will pause on the JNB instruction un-
til the TI bit is set (upon successful transmission of the character).

Advertising