EasyManuals Logo

ST STM32F31xx User Manual

ST STM32F31xx
584 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #452 background imageLoading...
Page #452 background image
General-purpose timers (TIM)
UM1581
452/584
DocID023800 Rev 1
22.2 TIM Firmware driver API description
The following section lists the various functions of the TIM library.
22.2.1 Output Compare management functions
TIM Driver: how to use it in Output Compare Mode
To use the Timer in Output Compare mode, the following steps are mandatory:
1. Enable TIM clock using RCC_APBxPeriphClockCmd(RCC_APBxPeriph_TIMx,
ENABLE) function
2. Configure the TIM pins by configuring the corresponding GPIO pins
3. Configure the Time base unit as described in the first part of this driver, if needed,
else the Timer will run with the default configuration:
 Autoreload value = 0xFFFF
 Prescaler value = 0x0000
 Counter mode = Up counting
 Clock Division = TIM_CKD_DIV1
4. Fill the TIM_OCInitStruct with the desired parameters including:
 The TIM Output Compare mode: TIM_OCMode
 TIM Output State: TIM_OutputState
 TIM Pulse value: TIM_Pulse
 TIM Output Compare Polarity : TIM_OCPolarity
5. Call TIM_OCxInit(TIMx, &TIM_OCInitStruct) to configure the desired channel with the
corresponding configuration
6. Call the TIM_Cmd(ENABLE) function to enable the TIM counter.
All other functions can be used separately to modify, if needed, a specific feature
of the Timer.
In case of PWM mode, this function is mandatory: TIM_OCxPreloadConfig(TIMx,
TIM_OCPreload_ENABLE);
If the corresponding interrupt or DMA request are needed, the user should:
1. Enable the NVIC (or the DMA) to use the TIM interrupts (or DMA requests).
2. Enable the corresponding interrupt (or DMA request) using the function
TIM_ITConfig(TIMx, TIM_IT_CCx) (or TIM_DMA_Cmd(TIMx,
TIM_DMA_CCx))
ï‚· TIM_OC1Init()
ï‚· TIM_OC2Init()
ï‚· TIM_OC3Init()
ï‚· TIM_OC4Init()
ï‚· TIM_OC5Init()
ï‚· TIM_OC6Init()
ï‚· TIM_SelectGC5C1()

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the ST STM32F31xx and is the answer not in the manual?

ST STM32F31xx Specifications

General IconGeneral
BrandST
ModelSTM32F31xx
CategoryMicrocontrollers
LanguageEnglish

Related product manuals