![LAPIS Semiconductor ML610472 User Manual Download Page 129](http://html1.mh-extra.com/html/lapis-semiconductor/ml610472/ml610472_user-manual_3645865129.webp)
ML610471/472/473/Q471/Q472/Q473 User's Manual
Chapter 9 Timer
9-15
9.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:
UA0BRTH, UA0BRTL = 500000/9600 – 1 = 51 (decimal) = 33 (hexadecimal) (See Section 11.3.2.)
However, actual 500kHz RC oscillation clock has temperature variation and production tolerance, the calculation by
using the fixed value of 500kHz cannot 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.
UART0 baud rate registers H and L are:
UA0BRTH, UA0BRTL = (frequency ratio between HTBCLK clock and baud rate) - 1 = (N1/128)-1 = N2 -1
(See Section 14.3.2.)
①
Round data in calculation
N1 = 1011101111110 (binary)
N2 = 101111 (binary) = 47 (decimal) = 2F (hexadecimal)
Set N2-1 (= 2E) to UA0BRTH and UA0BRTL registers. In this case, the actual baud-rate will be 9595.744681.. [bps],
so the accuracy = ((9595.744681/9600) -1)* 100= -0.04..[%].
②
Truncate data in calculation (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 actual baud-rate will be 9804.347826.. [bps],
so the accuracy = ((9804.347826/9600) -1)* 100= 2.12..[%].
Table 9-3 shows the baud rate and accuracy (theoretical) when the baud rate clock is set to 500KHz.
Table 9-3 Baud Rate and Accuracy (theoretical) for Baud Rate Clock Set to 500KHz
Baud-rate[bps]
Data setting to UA0BRTH register and UA0BRTH register
Theoretical
accuracy
300
Round off {N1/4 (2bit right-shift) } - (minus) 1.
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.
less than ±2%
19200
Round off {N1/256 (8bit right-shift) } - (minus) 1.
±2% to 2.5%
38400
Round off {N1/512 (9bit right-shift) } - (minus) 1.
more than ±2.5%
Summary of Contents for ML610472
Page 12: ...Chapter 1 Overview...
Page 38: ...Chapter 2 CPU and Memory Space...
Page 44: ...Chapter 3 Reset Function...
Page 48: ...Chapter 4 MCU Control Function...
Page 62: ...Chapter 5 Interrupts...
Page 82: ...Chapter 6 Clock Generation Circuit...
Page 94: ...Chapter 7 Time Base Counter...
Page 105: ...Chapter 8 Capture...
Page 114: ...Chapter 9 Timer...
Page 133: ...Chapter 10 Watchdog Timer...
Page 141: ...Chapter 11 UART...
Page 164: ...Chapter 12 Port 0...
Page 173: ...Chapter 13 Port 2...
Page 180: ...Chapter 14 Port 3...
Page 188: ...Chapter 15 Port 4...
Page 199: ...Chapter 16 Port 6...
Page 205: ...Chapter 17 RC Oscillation Type A D Converter...
Page 225: ...Chapter 18 LCD Drivers...
Page 243: ...Chapter 19 Power Supply Circuit...
Page 245: ...Chapter 20 uEASE Flash Writer System...
Page 249: ...Chapter 21 Software Development...
Page 258: ...Appendixes...
Page 280: ...Revision History...