
Rev. 1.21
138
�ove��e� ��� 2�1�
Rev. 1.21
13�
�ove��e� ��� 2�1�
HT66F488/HT66F489
A/D Flash MCU with EEPROM
HT66F488/HT66F489
A/D Flash MCU with EEPROM
Baud Rate Generator
To setup the speed of the serial data communication, the UART function contains its own dedicated
baud rate generator. The baud rate is controlled by its own internal free running 8-bit timer, the
period of which is determined by two factors. The first of these is the value placed in the baud rate
register BRG and the second is the value of the BRGH bit with the control register UCR2. The
BRGH bit decides if the baud rate generator is to be used in a high speed mode or low speed mode,
which in turn determines the formula that is used to calculate the baud rate. The value N in the BRG
register which is used in the following baud rate calculation formula determines the division factor.
Note that N is the decimal value placed in the BRG register and has a range of between 0 and 255.
UCR2 BRGH Bit
0
1
Baud Rate (BR)
f
SYS
/[64 (�+1)]
f
SYS
/[16 (�+1)]
By programming the BRGH bit which allows selection of the related formula and programming the
required value in the BRG register, the required baud rate can be setup. Note that because the actual
baud rate is determined using a discrete value, N, placed in the BRG register, there will be an error
associated between the actual and requested value. The following example shows how the BRG
register value N and the error value can be calculated.
Calculating the register and error values
For a clock frequency of
4
MHz, and with BRGH set to “0” determine the BRG register value N, the
actual baud rate and the error value for a desired baud rate of
4800
.
From the above table the desired baud rate BR = f
SYS
/[64 (N+1)]
Re-arranging this equation gives N = [f
SYS
/(BR×64)] - 1
Giving a value for N = [
4
000000 /(
48
00×64)] - 1 = 12.0208
To obtain the closest value, a decimal value of 12 should be placed into the BRG register. This gives
an actual or calculated baud rate value of BR =
4
000000 /[64×(12 + 1)] =
4808
Therefore the error is equal to (
4808
-
48
00) /
48
00 = 0.16%
The following tables show actual values of baud rate and error values for the two values of BRGH.
Baud Rate
K/BPS
Baud Rates for BRGH=0
f
SYS
= 16 MHz
f
SYS
= 20 MHz
BRG
Kbaud
Error (%)
BRG
Kbaud
Error (%)
�.3
—
—
—
—
—
—
1.2
2��
1.2�2
�.16
25�
1.2�2
�.16
2.4
1�3
2.4�4
�.16
12�
2.4�4
�.16
4.8
51
4.8�8
�.16
64
4.8�8
�.16
�.6
25
�.615
�.16
32
�.4��
-1.36
1�.2
12
1�.231
�.16
15
1�.531
1.�3
38.4
6
35.�14
-6.��
�
3�.�63
1.�3
5�.6
3
62.5
8.51
4
62.5
8.51
115.2
1
125
8.51
2
1�4.1�
-�.58
25�
�
25�
�
�
312.5
25
Baud Rates and Error Values for BRGH = 0