Rev. 1.20 68 January 23, 2015 Rev. 1.20 69 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 Modules – TM
Oneofthemostfundamentalfunctionsinanymicrocontrollerdeviceistheabilitytocontroland
measuretime.ToimplementtimerelatedfunctionsthedeviceincludesseveralTimerModules,
abbreviatedtothenameTM.TheTMsaremulti-purposetimingunitsandservetoprovide
operationssuchasTimer/Counter,InputCapture,CompareMatchOutputandSinglePulseOutput
aswellasbeingthefunctionalunitforthegenerationofPWMsignals.EachoftheTMshastwo
individualinterrupts.TheadditionofinputandoutputpinsforeachTMensuresthatusersare
providedwithtimingunitswithawideandexiblerangeoffeatures.
ThecommonfeaturesofthedifferentTMtypesaredescribedherewithmoredetailedinformation
providedintheindividualCompactandPeriodicTMsections.
Introduction
Eachdevicecontainsa10-bitCompactTM,CTM,anda10-bitPeriodicTM,PTM.Although
similarinnature,thedifferentTMtypesvaryintheirfeaturecomplexity.Thecommonfeaturesto
theCompactandPeriodicTMswillbedescribedinthissectionandthedetailedoperationwillbe
describedincorrespondingsections.Themainfeaturesanddifferencesbetweenthetwotypesof
TMsaresummarisedintheaccompanyingtable.
Function CTM PTM
Timer/Counter √ √
I/P Capture — √
Compare Match Output √ √
PWM Channels 1 1
Single Pulse Output — 1
PWM Alignment Edge Edge
PWM Adjustment Period & Duty Duty or Period Duty or Period
TM Function Summary
CTM0 PTM0
10-bit CTM 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~xTnCK0bitsinthexTMn
controlregisters,where"x"canstandforCorPand"n"istheserialnumber.Theclocksourcecan
bearatioofeitherthesystemclockf
SYS
ortheinternalhighclockf
H
,thef
SUB
clocksourceorthe
externalTCKnpin.TheTCKnpinclocksourceisusedtoallowanexternalsignaltodrivetheTM
asanexternalclocksourceorforeventcounting.