Rev. 1.20 124 January 23, 2015 Rev. 1.20 125 January 23, 2015
BS82B12A-3/BS82C16A-3/BS82D20A-3
Touch Key 8-Bit Flash MCU with LED/LCD Driver
BS82B12A-3/BS82C16A-3/BS82D20A-3
Touch Key 8-Bit Flash MCU with LED/LCD Driver
Calculating the Baud Rate and Error Values
Foraclockfrequencyof4MHz,andwithBRGHsetto"0"determinetheBRGregistervalueN,the
actualbaudrateandtheerrorvalueforadesiredbaudrateof4800.
FromtheabovetablethedesiredbaudrateBR=f
SYS
/[64(N+1)]
Re-arrangingthisequationgivesN=[f
SYS
/(BR×64)]-1
GivingavalueforN=[4000000/(4800×64)]-1=12.0208
Toobtaintheclosestvalue,adecimalvalueof12shouldbeplacedintotheBRGregister.Thisgives
anactualorcalculatedbaudratevalueofBR=4000000/[64×(12+1)]=4808
Thereforetheerrorisequalto(4808-4800)/4800=0.16%
ThefollowingtableshowsactualvaluesofbaudrateanderrorvaluesforthetwovaluesofBRGH.
Baud Rate
K/BPS
f
SYS
=8MHz
Baud Rates for BRGH=0 Baud Rates for BRGH=1
BRG Kbaud Error (%) BRG Kbaud Error (%)
0.3 — — — — — —
1.2
103 1.202 0.16 — — —
2.4
51 2.404 0.16 207 2.404 0.16
4.8
25 4.808 0.16 103 4.808 0.16
9.6 12
9.615 0.16 51 9.615 0.16
19.2 6
17.8857 -6.99 25 19.231 0.16
38.4 2 41.667 8.51 12 38.462 0.16
57.6 1 62.500 8.51 8 55.556 -3.55
115.2 0 125 8.51 3 125 8.51
250 — — — 1 250 0
Baud Rates and Error Values
UART Setup and Control
Fordatatransfer,theUARTfunctionutilizesanon-return-to-zero,morecommonlyknownasNRZ,
format.Thisiscomposedofonestartbit,eightorninedatabits,andoneortwostopbits.Parity
issupportedbytheUARThardware,andcanbesetuptobeeven,oddornoparity.Forthemost
commondataformat,8databitsalongwithnoparityandonestopbit,denotedas8,N,1,isused
asthedefaultsetting,whichisthesettingatpower-on.Thenumberofdatabitsandstopbits,along
withtheparity,aresetupbyprogrammingthecorrespondingBNO,PRT,PREN,andSTOPSbits
intheUCR1register.Thebaudrateusedtotransmitandreceivedataissetupusingtheinternal
8-bitbaudrategenerator,whilethedataistransmittedandreceivedLSBrst.AlthoughtheUART
transmitterandreceiverarefunctionallyindependent,theybothusethesamedataformatandbaud
rate.Inallcasesstopbitswillbeusedfordatatransmission.