
ML610Q421/ML610Q422/ML610421 User’s Manual
Chapter 10 Timers
10 – 23
10.3.3 16-bit timer frequency measurement mode application for setting uart baud-rate
For example, when the target baud-rate is 9600bps and the clock is HSCLK(500kHz), the UART0 baud-rate register
(UA0BRTH, UA0BRTL) should be set as follows. See Section 14.3.2. in UART chapter.
UA0BRTH, UA0BRTL = 500000/9600 - 1 = 51 (decimal) = 33(Hexadecimal)
However, actual 500kHz RC oscillation clock has temperature variation and production tolerance, the calculation by
using the fixed value of 500kHz can not make accurate baud-rate. To compensate it, count the frequency in the
frequency measurement mode to set the baud-rate again before operating UART communication.
After finishing the clock count in the frequency measurement mode, assuming HTBCLK is 451kHz, data of TM2C
register and TM3C register will be:
N1 = 451000 * 437 / 32768
= 6014 (Decimal)
= 177E (Hexadecimal)
= 1011101111110 (Binary)
As (437 / 32768) sec is equivalent to 128 clocks at 9600Hz (more precisely, 9598Hz), a division of the count
(N1) by 128 equals frequency ratio (N2) between the frequency of HTBCLK and 9600Hz.
For the calculation, the accuracy of baud-rate depends on truncating (1) or rounding (2) the data.
UA0BRTH regiser and UA0BRTL register have to be set as follows. See the previous secntion 10.3.2. and
section 14.3.2. in UART chapter.
UA0BRTH, UA0BRTL = (the frequency ratio of HTBCLK and 9600Hz) - 1 = (N1/128)-1 = N2 -1
(1)
Round data in caluculation
N1 = 1011101111110 (binary)
N2 = 101111 (binary) = 47 (decimal) = 2F (hexadecimal)
Set N2-1 (= 2E) to UA0BRTH and UA0BRTL registers.
In this case, the acual baud-rate will be 9595.744681.. [bps], so the accuracy = ((9595.744681/9600) -1)*
100= -0.04..[%].
(2) Trancate data in calucuation (the accuracy of baud-rate becomes worse)
N1 = 1011101111110 (binary)
N2 = 101110 (binary) = 46 (decimal) = 2E (hexadecimal)
Set N2-1 (= 2D) to UA0BRTH and UA0BRTL registers.
In this case, the acual baud-rate will be 9804.347826.. [bps], so the accuracy = ((9804.347826/9600) -1)*
100= 2.12..[%].
Table 10-5 shows a baud-rate and theoretical accuracy, and Table 10-6 shows a baud-rate and theoretical accuracy for P
Version.
Table 10-5
Baud-rate and theoretical accuracy
Baud-rate[bps]
Data setting to UA0BRTH register and UA0BRTH register
Theoretical accuracy
300
Round off {N1/4 (2bit right-shift) } - (minus) 1.
~ +/- 2%
600
Round off {N1/8 (3bit right-shift) } - (minus) 1.
1200
Round off {N1/16 (4bit right-shift) } - (minus) 1.
2400
Round off {N1/32 (5bit right-shift) } - (minus) 1.
4800
Round off {N1/64 (6bit right-shift) } - (minus) 1.
9600
Round off {N1/128 (7bit right-shift) } - (minus) 1.
19200
Round off {N1/256 (8bit right-shift) } - (minus) 1.
+/- 2% ~ 2.5%
38400
Round off {N1/512 (9bit right-shift) } - (minus) 1.
±
2.5% ~
57600
Round off {N1/768} - (minus) 1.
Содержание ML610421
Страница 1: ...ML610Q421 ML610Q422 ML610421 User s Manual Issue Date Feb 9 2015 FEUL610Q421 06...
Страница 15: ...Chapter 1 Overview...
Страница 44: ...Chapter 2 CPU and Memory Space...
Страница 49: ...Chapter 3 Reset Function...
Страница 53: ...Chapter 4 MCU Control Function...
Страница 69: ...Chapter 5 Interrupts INTs...
Страница 93: ...Chapter 6 Clock Generation Circuit...
Страница 110: ...Chapter 7 Time Base Counter...
Страница 121: ...Chapter 8 Capture...
Страница 129: ...Chapter 9 1 kHz Timer 1kHzTM...
Страница 135: ...Chapter 10 Timers...
Страница 160: ...Chapter 11 PWM...
Страница 172: ...Chapter 12 Watchdog Timer...
Страница 180: ...Chapter 13 Synchronous Serial Port...
Страница 195: ...Chapter 14 UART...
Страница 216: ...Chapter 15 I2 C Bus Interface...
Страница 231: ...Chapter 16 NMI Pin...
Страница 237: ...Chapter 17 Port 0...
Страница 246: ...Chapter 18 Port 1...
Страница 252: ...Chapter 19 Port 2...
Страница 259: ...Chapter 20 Port 3...
Страница 270: ...Chapter 21 Port 4...
Страница 282: ...Chapter 22 Port A...
Страница 290: ...Chapter 23 Melody Driver...
Страница 304: ...Chapter 24 RC Oscillation Type A D Converter...
Страница 327: ...Chapter 25 Successive Approximation Type A D Converter...
Страница 338: ...Chapter 26 LCD Drivers...
Страница 371: ...Chapter 27 Battery Level Detector...
Страница 378: ...Chapter 28 Power Supply Circuit...
Страница 381: ...Chapter 29 On Chip Debug Function...
Страница 384: ...Appendixes...
Страница 435: ...Revision History...