BS85B12-3/BS85C20-3/BS85C20-5
Touch Key Flash MCU with LCD/LED Driver
Timer/Counter Mode
Toꢀselectꢀthisꢀmode,ꢀbitsꢀTnAM1,ꢀTnAM0ꢀandꢀTnBM1,ꢀTnBM0ꢀinꢀtheꢀTMnC1ꢀandꢀTMnC2ꢀregisterꢀ
shouldꢀallꢀbeꢀsetꢀhigh.ꢀTheꢀTimer/CounterꢀModeꢀoperatesꢀinꢀanꢀidenticalꢀwayꢀtoꢀtheꢀCompareꢀ
MatchꢀOutputꢀModeꢀgeneratingꢀtheꢀsameꢀinterruptꢀflags.ꢀTheꢀexceptionꢀisꢀthatꢀinꢀtheꢀTimer/Counterꢀ
ModeꢀtheꢀTMꢀoutputꢀpinꢀisꢀnotꢀused.ꢀThereforeꢀtheꢀaboveꢀdescriptionꢀandꢀTimingꢀDiagramsꢀforꢀtheꢀ
CompareꢀMatchꢀOutputꢀModeꢀcanꢀbeꢀusedꢀtoꢀunderstandꢀitsꢀfunction.ꢀAsꢀtheꢀTMꢀoutputꢀpinꢀisꢀnotꢀ
usedꢀinꢀthisꢀmode,ꢀtheꢀpinꢀcanꢀbeꢀusedꢀasꢀaꢀnormalꢀI/Oꢀpinꢀorꢀotherꢀpin-sharedꢀfunction.
PWM Output Mode
Toꢀselectꢀthisꢀmode,ꢀtheꢀrequiredꢀbitꢀpairs,ꢀTnAM1,ꢀTnAM0ꢀandꢀTnBM1,ꢀTnBM0ꢀshouldꢀbeꢀsetꢀ
toꢀ10ꢀrespectivelyꢀandꢀalsoꢀtheꢀTnAIO1,ꢀTnAIO0ꢀandꢀTnBIO1,ꢀTnBIO0ꢀbitsꢀshouldꢀbeꢀsetꢀtoꢀ10ꢀ
respectively.ꢀTheꢀPWMꢀfunctionꢀwithinꢀtheꢀTMꢀisꢀusefulꢀforꢀapplicationsꢀwhichꢀrequireꢀfunctionsꢀ
suchꢀasꢀmotorꢀcontrol,ꢀheatingꢀcontrol,ꢀilluminationꢀcontrolꢀetc.ꢀByꢀprovidingꢀaꢀsignalꢀofꢀfixedꢀ
frequencyꢀbutꢀofꢀvaryingꢀdutyꢀcycleꢀonꢀtheꢀTMꢀoutputꢀpin,ꢀaꢀsquareꢀwaveꢀACꢀwaveformꢀcanꢀbeꢀ
generatedꢀwithꢀvaryingꢀequivalentꢀDCꢀRMSꢀvalues.
AsꢀbothꢀtheꢀperiodꢀandꢀdutyꢀcycleꢀofꢀtheꢀPWMꢀwaveformꢀcanꢀbeꢀcontrolled,ꢀtheꢀchoiceꢀofꢀgeneratedꢀ
waveformꢀisꢀextremelyꢀflexible.ꢀInꢀtheꢀPWMꢀmode,ꢀtheꢀTnCCLRꢀbitꢀisꢀusedꢀtoꢀdetermineꢀinꢀwhichꢀwayꢀ
theꢀPWMꢀperiodꢀisꢀcontrolled.ꢀWithꢀtheꢀTnCCLRꢀbitꢀsetꢀhigh,ꢀtheꢀPWMꢀperiodꢀcanꢀbeꢀfinelyꢀcontrolledꢀ
usingꢀtheꢀCCRAꢀregisters.ꢀInꢀthisꢀcaseꢀtheꢀCCRBꢀregistersꢀareꢀusedꢀtoꢀsetꢀtheꢀPWMꢀdutyꢀvalueꢀ(forꢀ
TPnBꢀoutputꢀpins).ꢀTheꢀCCRPꢀbitsꢀareꢀnotꢀusedꢀandꢀTPnAꢀoutputꢀpinꢀisꢀnotꢀused.ꢀTheꢀPWMꢀoutputꢀcanꢀ
onlyꢀbeꢀgeneratedꢀonꢀtheꢀTPnBꢀoutputꢀpins.ꢀWithꢀtheꢀTnCCLRꢀbitꢀclearedꢀtoꢀzero,ꢀtheꢀPWMꢀperiodꢀ
isꢀsetꢀusingꢀoneꢀofꢀtheꢀeightꢀvaluesꢀofꢀtheꢀthreeꢀCCRPꢀbits,ꢀinꢀmultiplesꢀofꢀ128.ꢀNowꢀbothꢀCCRAꢀandꢀ
CCRBꢀregistersꢀcanꢀbeꢀusedꢀtoꢀsetupꢀdifferentꢀdutyꢀcycleꢀvaluesꢀtoꢀprovideꢀdualꢀPWMꢀoutputsꢀonꢀtheirꢀ
relativeꢀTPnAꢀandꢀTPnBꢀpins.
TheꢀTnPWM1ꢀandꢀTnPWM0ꢀbitsꢀdetermineꢀtheꢀPWMꢀalignmentꢀtype,ꢀwhichꢀcanꢀbeꢀeitherꢀedgeꢀ
orꢀcentreꢀtype.ꢀInꢀedgeꢀalignment,ꢀtheꢀleadingꢀedgeꢀofꢀtheꢀPWMꢀsignalsꢀwillꢀallꢀbeꢀgeneratedꢀ
concurrentlyꢀwhenꢀtheꢀcounterꢀisꢀresetꢀtoꢀzero.ꢀWithꢀallꢀpowerꢀcurrentsꢀswitchingꢀonꢀatꢀtheꢀsameꢀ
time,ꢀthisꢀmayꢀgiveꢀriseꢀtoꢀproblemsꢀinꢀhigherꢀpowerꢀapplications.ꢀInꢀcentreꢀalignmentꢀtheꢀcentreꢀ
ofꢀtheꢀPWMꢀactiveꢀsignalsꢀwillꢀoccurꢀsequentially,ꢀthusꢀreducingꢀtheꢀlevelꢀofꢀsimultaneousꢀpowerꢀ
switchingꢀcurrents.
Interruptꢀflags,ꢀoneꢀforꢀeachꢀofꢀtheꢀCCRA,ꢀCCRBꢀandꢀCCRP,ꢀwillꢀbeꢀgeneratedꢀwhenꢀaꢀcompareꢀmatchꢀ
occursꢀfromꢀeitherꢀtheꢀComparatorꢀA,ꢀComparatorꢀBꢀorꢀComparatorꢀP.ꢀTheꢀTnAOCꢀandꢀTnBOCꢀbitsꢀinꢀ
theꢀTMnC1ꢀandꢀTMnC2ꢀregisterꢀareꢀusedꢀtoꢀselectꢀtheꢀrequiredꢀpolarityꢀofꢀtheꢀPWMꢀwaveformꢀwhileꢀ
theꢀtwoꢀTnAIO1,ꢀTnAIO0ꢀandꢀTnBIO1,ꢀTnBIO0ꢀbitsꢀpairsꢀareꢀusedꢀtoꢀenableꢀtheꢀPWMꢀoutputꢀorꢀtoꢀ
forceꢀtheꢀTMꢀoutputꢀpinꢀtoꢀaꢀfixedꢀhighꢀorꢀlowꢀlevel.ꢀTheꢀTnAPOLꢀandꢀTnBPOLꢀbitꢀareꢀusedꢀtoꢀreverseꢀ
theꢀpolarityꢀofꢀtheꢀPWMꢀoutputꢀwaveform.
Rev. 1.20
105
�ꢀꢁꢀst 10ꢂ 2012