Maxim Integrated Secure Microcontroller User Manual

Page 127

Advertising
background image

Secure Microcontroller User’s Guide

127 of 187

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 enables serial interrupts. Note that although a timer is used to generate
serial baud rates, the timer interrupt is not used. As mentioned above, this example uses a high priority for
the serial interrupt by setting the PS bit to a logic 1. This is done as follows:

IP–0B8h

RWT

PS

PT1

PX1

PT0

PX0

0

0

0

1

0

0

0

0

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, the 11.0592MHz
crystal assumed for this example generates good baud rate values. This is a commonly used choice for
generating baud rates. Other convenient values are 7.3728MHz and 1.8432MHz.

To get 9600 bits per second, the baud rate generator must create an interval of

1/9600 seconds = 1.0416ms. To get 19,200 bits per second, the interval is 1/19200 = 520.83µs. Note that
the timers count up, so the value that the timer starts from must be selected to generate the desired
interval.

1/11.0592MHz = t

CLK

= 90.4 x 10

-9

Timer runs at 12 t

CLK

per count = 1.085 x 10

-6

Time out = (256 - timer start value) x 12 t

CLK

= (256 - timer start value) x 1.085 x 10

-6

Serial port baud-rate clock = 1/baud rate = (16 or 32) x timeout

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 commonly referred to by the expression (2

SMOD

)/32.

Since SMOD is either 0 or 1, this value is either 1/32 or 2/32 respectively.

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

Baud Rate =

32

SMOD

2

X

TH1)

-

(256

*

12t

1

CLK


This formula solves as:

TH1 = 256 -

BaudRate

*

t

12

*

32

2

CLK

SMOD


For 9600 = Baud rate, TH1 = FDh with SMOD = 0.

Advertising