February2012DocID022500Rev11/27AN4013ApplicationnoteSTM32F1xx,STM32F2xx,STM32F4xx,STM32L1xxtimeroverview1IntroductionThisdocument:●presentsanoverviewofthetimerperipheralsintheSTM32F1xx,STM32F2xx,STM32F4xxandSTM32L1xxmicrocontrollerfamilies,●describesthevariousmodesandspecificfeaturesofthetimers,suchasclocksources,●explainshowtousetheavailablemodesandfeatures,●explainshowtocomputethetimebaseineachconfiguration,●describesthetimersynchronizationsequencesandtheadvancedfeaturesformotorcontrolapplications,inadditiontothebasictimermodes.Foreachmode,typicalconfigurationsarepresentedandexamplesofhowtousethemodesareprovided.Intherestofthisdocument(unlessotherwisespecified),thetermSTM32xxisusedtorefertoSTM32F1xx,STM32F2xx,STM32F4xxandSTM32L1xxmicrocontrollerfamilies.:●Generalpurposetimersareusedinanyapplicationforoutputcompare(timinganddelaygeneration),one-pulsemode,inputcapture(forexternalsignalfrequencymeasurement),sensorinterface(encoder,hallsensor)...●Advancedtimers:thesetimershavethemostfeatures.Inadditiontogeneralpurposefunctions,theyincludeseveralfeaturesrelatedtomotorcontrolanddigitalpowerconversionapplications:threecomplementarysignalswithdeadtimeinsertion,emergencyshut-downinput.●Oneortwochanneltimers:usedasgeneralpurposetimerswithalimitednumberofchannels.●Oneortwochanneltimerswithcomplementaryoutput:sameasprevioustype,buthavingadeadtimegeneratorononechannel.Thisallowshavingcomplementarysignalswithatimebaseindependentfromtheadvancedtimers.●Basictimershavenoinput/outputsandareusedeitherastimebasetimersorfortriggeringtheDACperipheral.Table1summarizestheSTM32familytimers.Table2presentsageneraloverviewoftimerfeatures.OverviewAN40134/27DocID022500Rev1Table1.STM32familytimersTimertypeSTM32F101/102/103/105/107familiesSTM32F100familySTM32L1familySTM32F2andSTM32F4familiesAdvancedTIM1TIM1TIM1TIM8TIM8Generalpurpose16-bitTIM2TIM2TIM2TIM3TIM3TIM3TIM3TIM4TIM4TIM4TIM4TIM5TIM532-bitTIM2TIM5BasicTIM6TIM6TIM6TIM6TIM7TIM7TIM7TIM71-channelTIM10TIM10TIM10TIM11TIM11TIM11TIM13TIM13TIM13TIM14TIM14TIM142-channelTIM9TIM9TIM9TIM12TIM12TIM121-channelwithonecomplementaryoutputTIM152-channelwithonecomplementaryoutputTIM16TIM17AN4013OverviewDocID022500Rev15/27Table2.TimerfeaturesoverviewTimertypeCounterresolutionCountertypeDMAChannelsComp.channelsSynchronizationMasterconfig.Slaveconfig.Advanced16bitup,downandcenteralignedYes43YesYesGeneralpurpose16bit32bit(1)up,downandcenteralignedYes40YesYesBasic16bitupYes00YesNo1-channel16bitupNo10Yes(OCsignal)No2-channel16bitupNo20YesYes1-channelwithonecomplementaryoutput16bitupYes11Yes(OCsignal)No2-channelwithonecomplementaryoutput16bitupYes21NoYes1.TIM2andTIM5are32-bitcounterresolutionintheSTM32F2andSTM32F4families.BasictimermodesAN40136/27DocID022500Rev13BasictimermodesBasictimerscanbeprogrammedtoworkinoneofthefollowingconfigurations.3.1ClockinputsourcesThetimercanbesynchronizedbyseveralclockssimultaneously:●Internalclock●Externalclock–Externalmode1(TI1orTI2pins)–Externalclockmode2(ETRpin)–Internaltriggerclock(ITRx)3.1.1InternalclockThetimerisclockedbydefaultbytheinternalclockprovidedfromtheRCC.Toselectthisclocksource,theSMCR_SMS(ifpresent)bitsshouldbereset.3.1.2ExternalclockTheexte