Rev. 1.50 162 August 28, 2017 Rev. 1.50 163 August 28, 2017
HT66F0175/HT66F0185
A/D Flash MCU with EEPROM
HT66F0175/HT66F0185
A/D Flash MCU with EEPROM
Baud Rate Generator
Tosetupthespeedoftheserialdatacommunication,theUARTfunctioncontainsitsowndedicated
baudrategenerator.Thebaudrateiscontrolledbyitsowninternalfreerunning8-bitcounter,the
periodofwhichisdeterminedbytwofactors.ThefirstoftheseisthevalueplacedintheBRG
registerandthesecondisthevalueoftheBRGHbitwithintheUCR2controlregister.TheBRGH
bitdecides,ifthebaudrategeneratoristobeusedinahighspeedmodeorlowspeedmode,which
inturndeterminestheformulathatisusedtocalculatethebaudrate.ThevalueintheBRGregister,
N,whichisusedinthefollowingbaudratecalculationformuladeterminesthedivisionfactor.Note
thatNisthedecimalvalueplacedintheBRGregisterandhasarangeofbetween0and255.
UCR2 BRGH Bit 0 1
Baud Rate (BR)
f
SYS
[64(N+1)]
f
SYS
[16(N+1)]
ByprogrammingtheBRGHbitwhichallowsselectionoftherelatedformulaandprogrammingthe
requiredvalueintheBRGregister,therequiredbaudratecanbesetup.Notethatbecausetheactual
baudrateisdeterminedusingadiscretevalue,N,placedintheBRGregister,therewillbeanerror
associatedbetweentheactualandrequestedvalue.ThefollowingexampleshowshowtheBRG
registervalueNandtheerrorvaluecanbecalculated.
BRG Register
Bit 7 6 5 4 3 2 1 0
Name BRG7 BRG6 BRG5 BRG4 BRG3 BRG2 BRG1 BRG0
R/W R/W R/W R/W R/W R/W R/W R/W R/W
POR x x x x x x x x
“x”: unknown
Bit7~0 BRG7~BRG0:BaudRatevalues
ByprogrammingtheBRGHbitintheUCR2registerwhichallowsselectionofthe
relatedformuladescribedaboveandprogrammingtherequiredvalueintheBRG
register,therequiredbaudratecanbesetup.
Calculating the Baud Rate and Error Values
Foraclockfrequencyof4MHz,andwithBRGHsetto0determinetheBRGregistervalueN,the
actualbaudrateandtheerrorvalueforadesiredbaudrateof4800.
FromtheabovetablethedesiredbaudrateBR=
SYS
[64(N+1)]
Re-arrangingthisequationgivesN=
SYS
(BR×64)
-1
GivingavalueforN=
4000000
(4800×64)
-1=12.0208
Toobtaintheclosestvalue,adecimalvalueof12shouldbeplacedintotheBRGregister.Thisgives
anactualorcalculatedbaudratevalueofBR=
[64(12+1)]
=4808
Thereforetheerrorisequalto
4808-4800
=0.16%