USER'S GUIDE

SM0 = 0 and SM1 = 1 corresponds to the value SCON.7

=0 and SCON.6 = 1. In addition the since the applica- tion requires receiving data, the serial receiver must be

SCON ± 98h

 

 

 

SM0

SM1

SM2

REN

0

1

0

1

enabled. This is done by setting the REN bit at SCON.4 to a logic 1. The remaining bits in SCON can be written to 0. Thus the value for SCON is 01010000b or 50h.

TB8

RB8

TI

RI

0

0

0

0

This application uses the serial interrupt. It serves two purposes. First, the software knows when a byte has been sent, so it knows when another can be written. Second, after the 256 bytes have been transmitted, the PC will respond. It is not know when this will occur and the software may have other tasks to attend. Therefore

IE ± 0A8h

 

 

 

EA

±

±

ES

1

0

0

1

the serial interrupt will inform the microcontroller when the confirmation code has been received by the serial port. This example will enable only the serial Interrupt. It will be set for high priority since in a real system, other interrupts might be enabled.

ET1

EX1

ET0

EX0

0

0

0

0

To enable interrupts, the EA bit must be set. In addition, the setting the ES bit turns on the Serial Interrupt. Thus the value 10010000b or 90h will enable serial interrupts. Note that although a timer will ultimately be used to gen-

IP ± 0B8h

 

 

 

RWT

±

±

PS

0

0

0

1

The serial port interrupt has been set to a high priority by setting the PS bit to a logic 1. Thus the serial port is con- figured for high priority by writing a 00010000b or 10h to the IP register at location 0B8h.

The serial port is now configured. The only remaining task is to set the correct baud rate. The example stated above that the communication rate would be either 9600 or 19,200 baud. To generate baud rates in Serial Mode 1, the Timer 1 is used. The serial port uses the Timer 1 overflow, then divides this frequency by either 16 or 32 to generate the internal baud rate clock. Each time the Timer 1 value increments past 0FFh is considered an overflow. Due to the formula used for generating baud rates shown below, the 11.0592 MHz crystal assumed for this example generates good baud rate values. This is the most convenient and commonly used choice for generating baud rates. Other convenient values are 7.3728 MHz and 1.8432 MHz.

To get 9600 bits per second, the baud rate generator must create an interval af 1/9600 seconds = 1.0416 ms. To get 19,200 bits per second, the interval is 1/19200 = 520.83 μs. Note that the timers count up, so the value

erate serial baud rates, the timer interrupt is not used. As mentioned above, this example will use a high prior- ity for the serial interrupt. This is done as follows.

PT1

PX1

PT0

PX0

0

0

0

0

that the timer starts from must be selected to generate the desired interval. The following values are useful:

1/11.0592 MHz = tCLK = 90.4 *10 ±9

Timer runs at 12 tCLK per count = 1.085 * 10 ±6

Time out = (256 ± Timer start value) * 12 tCLK = (256 ± Timer start value) * 1.085 * 10 ±6

serial port Baud rate clock = 1/baud rate = (16 or 32) * Time out

Whether 16 or 32 is used in the baud rate generator is determined by the SMOD bit at PCON.7. 16 is used for SMOD=1, and 32 is used for SMOD=0. This is com- monly referred to by the expression (2SMOD)/32. Since SMOD is either 0 or 1, this value is either 1/32 or 2/32 respectively.

The user selects the time±out value and the setting for SMOD to set the baud rate. This is done as follows.

Baud Rate

+

2SMOD

X

 

1

32

12tCLK

* (256 * TH1)

 

 

 

050396 120/173

121

Page 121
Image 121
Mitsubishi DS5000TK, DS907x SIP manual SM0 SM1 SM2 REN, TB8 RB8, ET1 EX1 ET0 EX0, PT1 PX1 PT0 PX0