Rev. 1.71 90 April 11, 2017 Rev. 1.71 91 April 11, 2017
HT66F002/HT66F0025/HT66F003/HT66F004
Cost-Effective A/D Flash MCU with EEPROM
HT66F002/HT66F0025/HT66F003/HT66F004
Cost-Effective A/D Flash MCU with EEPROM
Timer/Counter Mode
Toselectthismode,bitsPTnM1andPTnM0inthePTMnC1registershouldallbesetto11
respectively.TheTimer/CounterModeoperatesinanidenticalwaytotheCompareMatchOutput
Modegeneratingthesameinterruptflags.TheexceptionisthatintheTimer/CounterModethe
TMoutputpinisnotused.ThereforetheabovedescriptionandTimingDiagramsfortheCompare
MatchOutputModecanbeusedtounderstanditsfunction.AstheTMoutputpinisnotusedinthis
mode,thepincanbeusedasanormalI/Opinorotherpin-sharedfunction.
PWM Output Mode
Toselectthismode,bitsPTnM1andPTnM0inthePTMnC1registershouldbesetto10respectively
andalsothePTnIO1andPTnIO0bitsshouldbesetto10respectively.ThePWMfunctionwithin
theTMisusefulforapplicationswhichrequirefunctionssuchasmotorcontrol,heatingcontrol,
illuminationcontroletc.Byprovidingasignalofxedfrequencybutofvaryingdutycycleonthe
TMoutputpin,asquarewaveACwaveformcanbegeneratedwithvaryingequivalentDCRMS
values.
AsboththeperiodanddutycycleofthePWMwaveformcanbecontrolled,thechoiceofgenerated
waveformisextremelyexible.InthePWMmode,thePTnCCLRbithasnoeffectasthePWM
period.BothoftheCCRPandCCRAregistersareusedtogeneratethePWMwaveform,oneregister
isusedtocleartheinternalcounterandthuscontrolthePWMwaveformfrequency,whiletheother
oneisusedtocontrolthedutycycle.ThePWMwaveformfrequencyanddutycyclecantherefore
becontrolledbythevaluesintheCCRAandCCRPregisters.
Aninterruptag,oneforeachoftheCCRAandCCRP,willbegeneratedwhenacomparematch
occursfromeitherComparatorAorComparatorP.ThePTnOCbitinthePTMnC1registerisusedto
selecttherequiredpolarityofthePWMwaveformwhilethetwoPTnIO1andPTnIO0bitsareused
toenablethePWMoutputortoforcetheTMoutputpintoaxedhighorlowlevel.ThePTnPOL
bitisusedtoreversethepolarityofthePWMoutputwaveform.
• 10-bit PWM Mode, Edge-aligned Mode
CCRP CCRP = 0~1024
Period
CCRP=0 : period= 1024 clocks
CCRP=1~1023: period=1~1023 clocks
Duty CCRA
Iff
SYS
=16MHz,PTMclocksourceselectf
SYS
/4,CCRP=512andCCRA=128,
ThePTMPWMoutputfrequency=(f
SYS
/4)/512=f
SYS
/2048=7.8125kHz,duty=128/512=25%
IftheDutyvaluedenedbytheCCRAregisterisequaltoorgreaterthanthePeriodvalue,thenthe
PWMoutputdutyis100%.