Rev. 1.20 92 January 23, 2015 Rev. 1.20 93 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/Counter Mode
Toselectthismode,bitsPT0M1andPT0M0inthePTM0C1registershouldbesetto11
respectively.TheTimer/CounterModeoperatesinanidenticalwaytotheCompareMatchOutput
Modegeneratingthesameinterruptflags.TheexceptionisthatintheTimer/CounterModethe
PTM0outputpinisnotused.ThereforetheabovedescriptionandTimingDiagramsfortheCompare
MatchOutputModecanbeusedtounderstanditsfunction.
PWM Output Mode
Toselectthismode,bitsPT0M1andPT0M0inthePTM0C1registershouldbesetto10
respectively.ThePWMfunctionwithinthePTM0isusefulforapplicationswhichrequirefunctions
suchasmotorcontrol,heatingcontrol,illuminationcontroletc.Byprovidingasignaloffixed
frequencybutofvaryingdutycycleonthePTM0outputpin,asquarewaveACwaveformcanbe
generatedwithvaryingequivalentDCRMSvalues.
AsboththeperiodanddutycycleofthePWMwaveformcanbecontrolled,thechoiceofgenerated
waveformisextremelyexible.InthePWMOutputMode,thePT0CCLRbithasnoeffectonthe
PWMoperation.BothoftheCCRAandCCRPregistersareusedtogeneratethePWMwaveform,
oneregisterisusedtocleartheinternalcounterandthuscontrolthePWMwaveformfrequency,
whiletheotheroneisusedtocontrolthedutycycle.ThePWMwaveformfrequencyanddutycycle
canthereforebecontrolledbythevaluesintheCCRAandCCRPregisters.
Aninterruptag,oneforeachoftheCCRAandCCRP,willbegeneratedwhenacomparematch
occursfromeitherComparatorAorComparatorP.ThePT0OCbitinthePTM0C1registerisused
toselecttherequiredpolarityofthePWMwaveformwhilethetwoPT0IO1andPT0IO0bitsare
usedtoenablethePWMoutputortoforcethePTM0outputpintoaxedhighorlowlevel.The
PT0POLbitisusedtoreversethepolarityofthePWMoutputwaveform.
10-bit PTM, PWM Mode, Edge-aligned Mode
CCRP 1~1023 0
Period 1~1023 1024
Duty CCRA
Iff
SYS
=16MHz,PTM0clocksourceselectf
SYS
/4,CCRP=512andCCRA=128,
ThePTM0PWMoutputfrequency=(f
SYS
/4)/512=f
SYS
/2048=7.8125kHz,duty=128/512=25%,
IftheDutyvaluedenedbytheCCRAregisterisequaltoorgreaterthanthePeriodvalue,thenthe
PWMoutputdutyis100%.