Rev. 1.20 76 January 23, 2015 Rev. 1.20 77 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
Timer/counterMode
Unused
ThesetwobitsareusedtodeterminehowtheCTM0outputpinchangesstatewhena
certainconditionisreached.Thefunctionthatthesebitsselectdependsuponinwhich
modetheCTM0isrunning.
IntheCompareMatchOutputMode,theCT0IO1andCT0IO0bitsdeterminehowthe
CTM0outputpinchangesstatewhenacomparematchoccursfromtheComparatorA.
TheCTM0outputpincanbesetuptoswitchhigh,switchlowortotoggleitspresent
statewhenacomparematchoccursfromtheComparatorA.Whenthebitsareboth
zero,thennochangewilltakeplaceontheoutput.TheinitialvalueoftheCTM0
outputpinshouldbesetupusingtheCT0OCbitintheCTM0C1register.Notethat
theoutputlevelrequestedbytheCT0IO1andCT0IO0bitsmustbedifferentfromthe
initialvaluesetupusingtheCT0OCbitotherwisenochangewilloccurontheCTM0
outputpinwhenacomparematchoccurs.AftertheCTM0outputpinchangesstate
itcanberesettoitsinitiallevelbychangingtheleveloftheCT0ONbitfromlowto
high.InthePWMMode,theCT0IO1andCT0IO0bitsdeterminehowtheCTM0
outputpinchangesstatewhenacertaincomparematchconditionoccurs.ThePWM
outputfunctionismodiedbychangingthesetwobits.Itisnecessarytoonlychange
thevaluesoftheCT0IO1andCT0IO0bitsonlyaftertheCTM0hasbeenswitchedoff.
UnpredictablePWMoutputswilloccuriftheCT0IO1andCT0IO0bitsarechanged
whenTheCTM0isrunning.
Bit3 CT0OC:TP0Outputcontrolbit
CompareMatchOutputMode
0:Initiallow
1:Initialhigh
PWMMode
0:Activelow
1:Activehigh
ThisistheoutputcontrolbitfortheCTM0outputpin.Itsoperationdependsupon
whetherCTM0isbeingusedintheCompareMatchOutputModeorinthePWM
Mode.IthasnoeffectiftheCTM0isintheTimer/CounterMode.IntheCompare
MatchOutputModeitdeterminesthelogicleveloftheCTM0outputpinbeforea
comparematchoccurs.InthePWMModeitdeterminesifthePWMsignalisactive
highoractivelow.
Bit2 CT0POL:TP0OutputpolarityControl
0:Non-invert
1:Invert
ThisbitcontrolsthepolarityoftheCTM0outputpin.Whenthebitissethighthe
CTM0outputpinwillbeinvertedandnotinvertedwhenthebitiszero.Ithasnoeffect
iftheCTM0isintheTimer/CounterMode.
Bit1 CT0DPX:CTM0PWMperiod/dutyControl
0:CCRP-period;CCRA-duty
1:CCRP-duty;CCRA-period
Thisbit,determineswhichoftheCCRAandCCRPregistersareusedforperiodand
dutycontrolofthePWMwaveform.
Bit0 CT0CCLR:SelectCTMCounterclearcondition
0:CTM0ComparatrorPmatch
1:CTM0ComparatrorAmatch
Thisbitisusedtoselectthemethodwhichclearsthecounter.Rememberthatthe
CompactCTM0containstwocomparators,ComparatorAandComparatorP,eitherof
whichcanbeselectedtocleartheinternalcounter.WiththeCT0CCLRbitsethigh,
thecounterwillbeclearedwhenacomparematchoccursfromtheComparatorA.
Whenthebitislow,thecounterwillbeclearedwhenacomparematchoccursfrom
theComparatorPorwithacounteroverow.Acounteroverowclearingmethodcan
onlybeimplementediftheCCRPbitsareallclearedtozero.TheCT0CCLRbitisnot
usedinthePWMMode.