Rev. 1.71 66 April 11, 2017 Rev. 1.71 67 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 Modules – TM
Oneofthemostfundamentalfunctionsinanymicrocontrollerdeviceistheabilitytocontroland
measuretime.ToimplementtimerelatedfunctionsthedevicesincludeseveralTimerModules,
abbreviatedtothenameTM.TheTMsaremulti-purposetimingunitsandservetoprovide
operationssuchasTimer/Counter,InputCapture,CompareMatchOutputandSinglePulseOutput
aswellasbeingthefunctionalunitforthegenerationofPWMsignals.EachoftheTMshastwo
individualinterrupts.TheadditionofinputandoutputpinsforeachTMensuresthatusersare
providedwithtimingunitswithawideandexiblerangeoffeatures.
ThecommonfeaturesofthedifferentTMtypesaredescribedherewithmoredetailedinformation
providedintheindividualStandardandPeriodicTMsections.
Introduction
ThedevicescontainoneortwoTMsdependinguponwhichdeviceisselectedwitheachTMhaving
areferencenameofTM0~TM1.EachindividualTMcanbecategorisedasacertaintype,namely
StandardTypeTMorPeriodicTypeTM.Althoughsimilarinnature,thedifferentTMtypesvaryin
theirfeaturecomplexity.ThecommonfeaturestotheStandardandPeriodicTMswillbedescribed
inthissectionandthedetailedoperationwillbedescribedincorrespondingsections.Themain
featuresanddifferencesbetweenthetwotypesofTMsaresummarisedintheaccompanyingtable.
Function STM PTM
Timer/Counter √ √
I/P Capture √ √
Compare Match Output √ √
PWM Channels 1 1
Single Pulse Output 1 1
PWM Alignment Edge Edge
PWM Adjustment Period & Duty Duty or Period Duty or Period
TM Function Summary
Device TM0 TM1
HT66F002/HT66F0025 10-bit STM —
HT66F003 10-bit STM 10-bit PTM
HT66F004 10-bit PTM 10-bit PTM
TM Name/Type Reference
TM Operation
ThetwodifferenttypesofTMsofferadiverserangeoffunctions,fromsimpletimingoperations
toPWMsignalgeneration.ThekeytounderstandinghowtheTMoperatesistoseeitintermsof
afreerunningcounterwhosevalueisthencomparedwiththevalueofpre-programmedinternal
comparators.Whenthefreerunningcounterhasthesamevalueasthepre-programmedcomparator,
knownasacomparematchsituation,aTMinterruptsignalwillbegeneratedwhichcanclearthe
counterandperhapsalsochangetheconditionoftheTMoutputpin.TheinternalTMcounteris
drivenbyauserselectableclocksource,whichcanbeaninternalclockoranexternalpin.
TM Clock Source
TheclocksourcewhichdrivesthemaincounterineachTMcanoriginatefromvarioussources.The
selectionoftherequiredclocksourceisimplementedusingthexTnCK2~xTnCK0bitsinthexTM
controlregisters.Theclocksourcecanbearatioofeitherthesystemclockf
SYS
ortheinternalhigh
clockf
H
,thef
TBC
clocksourceortheexternalxTCKnpin.ThexTCKnpinclocksourceisusedto
allowanexternalsignaltodrivetheTMasanexternalclocksourceorforeventcounting.