STM8L15x Standard Peripherals Drivers: Output Compare management functions

STM8L15x/16x Standard Peripherals Drivers

STM8L15x Standard Peripherals Drivers

Output Compare management functions

Output Compare management functions. More...

Modules

 Input Capture management functions
 

Input Capture management functions.

 Interrupts DMA and flags management functions
 

Interrupts, DMA and flags management functions.


 Clocks management functions
 

Clocks management functions.


 Synchronization management functions
 

Synchronization management functions.


 Specific interface management functions
 

Specific interface management functions.


Functions

static void TI1_Config (TIM3_ICPolarity_TypeDef TIM3_ICPolarity, TIM3_ICSelection_TypeDef TIM3_ICSelection, uint8_t TIM3_ICFilter)
 Configure the TI1 as Input.
static void TI2_Config (TIM3_ICPolarity_TypeDef TIM3_ICPolarity, TIM3_ICSelection_TypeDef TIM3_ICSelection, uint8_t TIM3_ICFilter)
 Configure the TI2 as Input.
void TIM3_BKRConfig (TIM3_OSSIState_TypeDef TIM3_OSSIState, TIM3_LockLevel_TypeDef TIM3_LockLevel, TIM3_BreakState_TypeDef TIM3_BreakState, TIM3_BreakPolarity_TypeDef TIM3_BreakPolarity, TIM3_AutomaticOutput_TypeDef TIM3_AutomaticOutput)
 Configures the Break feature, dead time, Lock level, the OSSI, and the AOE(automatic output enable).
void TIM3_CCxCmd (TIM3_Channel_TypeDef TIM3_Channel, FunctionalState NewState)
 Enables or disables the TIM3 Capture Compare Channel x.
void TIM3_CtrlPWMOutputs (FunctionalState NewState)
 Enables or disables the TIM3 peripheral Main Outputs.
void TIM3_ForcedOC1Config (TIM3_ForcedAction_TypeDef TIM3_ForcedAction)
 Forces the TIM3 Channel1 output waveform to active or inactive level.
void TIM3_ForcedOC2Config (TIM3_ForcedAction_TypeDef TIM3_ForcedAction)
 Forces the TIM3 Channel2 output waveform to active or inactive level.
void TIM3_OC1FastConfig (FunctionalState NewState)
 Configures the TIM3 Capture Compare 1 Fast feature.
void TIM3_OC1Init (TIM3_OCMode_TypeDef TIM3_OCMode, TIM3_OutputState_TypeDef TIM3_OutputState, uint16_t TIM3_Pulse, TIM3_OCPolarity_TypeDef TIM3_OCPolarity, TIM3_OCIdleState_TypeDef TIM3_OCIdleState)
 Initializes the TIM3 Channel1 according to the specified parameters.
void TIM3_OC1PolarityConfig (TIM3_OCPolarity_TypeDef TIM3_OCPolarity)
 Configures the TIM3 Channel 1 polarity.
void TIM3_OC1PreloadConfig (FunctionalState NewState)
 Enables or disables the TIM3 peripheral Preload Register on CCR1.
void TIM3_OC2FastConfig (FunctionalState NewState)
 Configures the TIM3 Capture Compare 2 Fast feature.
void TIM3_OC2Init (TIM3_OCMode_TypeDef TIM3_OCMode, TIM3_OutputState_TypeDef TIM3_OutputState, uint16_t TIM3_Pulse, TIM3_OCPolarity_TypeDef TIM3_OCPolarity, TIM3_OCIdleState_TypeDef TIM3_OCIdleState)
 Initializes the TIM3 Channel2 according to the specified parameters.
void TIM3_OC2PolarityConfig (TIM3_OCPolarity_TypeDef TIM3_OCPolarity)
 Configures the TIM3 Channel 2 polarity.
void TIM3_OC2PreloadConfig (FunctionalState NewState)
 Enables or disables the TIM3 peripheral Preload Register on CCR2.
void TIM3_SelectOCxM (TIM3_Channel_TypeDef TIM3_Channel, TIM3_OCMode_TypeDef TIM3_OCMode)
 Selects the TIM3 Output Compare Mode.
void TIM3_SetCompare1 (uint16_t Compare)
 Sets the TIM3 Capture Compare1 Register value.
void TIM3_SetCompare2 (uint16_t Compare)
 Sets the TIM3 Capture Compare2 Register value.

Detailed Description

Output Compare management functions.

 ===============================================================================
                        Output Compare management functions
 ===============================================================================  
   
       ===================================================================      
              TIM3 Driver: how to use it in Output Compare Mode
       =================================================================== 
       To use the Timer in Output Compare mode, the following steps are mandatory:
       
       1. Enable TIM3 clock using CLK_PeripheralClockConfig(CLK_Peripheral_TIM3, ENABLE) function.
       
       2. Configure the TIM3 pins in output mode by configuring the corresponding GPIO pins
          
       3. Configure the Time base unit as described in the first part of this driver, if needed,
          otherwise the Timer will run with the default configuration:
          - Autoreload value = 0xFFFF
          - Prescaler value = 0x0000
          - Counter mode = Up counting
      
       4. Call TIM3_OCxInit() to configure the channel x with the desired parameters
          including:
          - TIM3 Output Compare mode: TIM3_OCMode
          - TIM3 Output State: TIM3_OutputState
          - TIM3 Pulse value: TIM3_Pulse
          - TIM3 Output Compare Polarity: TIM3_OCPolarity
          - TIM3 Output Idle State: TIM3_OCIdleState
       
       5. Call the TIM3_Cmd(ENABLE) function to enable the TIM3 counter.
       
       Note1: All other functions can be used separately to modify, if needed,
          a specific feature of the Timer. 
       
       Note2: If the corresponding interrupt or DMA request are needed, the user should:
              1. Enable global interrupts (or the DMA) to use the TIM3 interrupts (or DMA requests). 
              2. Enable the corresponding interrupt (or DMA request) using the function 
              TIM3_ITConfig(TIM3_IT_CCx) (or TIM3_DMACmd(TIM3_DMASource_CCx))   


Function Documentation

static void TI1_Config ( TIM3_ICPolarity_TypeDef  TIM3_ICPolarity,
TIM3_ICSelection_TypeDef  TIM3_ICSelection,
uint8_t  TIM3_ICFilter 
) [static]

Configure the TI1 as Input.

Parameters:
TIM3_ICPolarity,:Input Capture Polarity This parameter can be one of the following values:
  • TIM3_ICPolarity_Rising: Input Capture on Rising Edge
  • TIM3_ICPolarity_Falling: Input Capture on Falling Edge
TIM3_ICSelection,:Specifies the input to be used. This parameter can be one of the following values:
  • TIM3_ICSelection_DirectTI: Input Capture mapped on the direct input
  • TIM3_ICSelection_IndirectTI: Input Capture mapped on the indirect input
  • TIM3_ICSelection_TRGI: Input Capture mapped on the Trigger Input
TIM3_ICFilter,:Specifies the Input Capture Filter. This parameter must be a value between 0x00 and 0x0F.
Return values:
None

Definition at line 2044 of file stm8l15x_tim3.c.

References IS_TIM3_IC_FILTER, IS_TIM3_IC_POLARITY, IS_TIM3_IC_SELECTION, TIM3, TIM3_ICPolarity_Falling, TIM_CCER1_CC1E, TIM_CCER1_CC1P, TIM_CCMR_CCxS, and TIM_CCMR_ICxF.

Referenced by TIM3_ICInit(), TIM3_PWMIConfig(), and TIM3_TIxExternalClockConfig().

static void TI2_Config ( TIM3_ICPolarity_TypeDef  TIM3_ICPolarity,
TIM3_ICSelection_TypeDef  TIM3_ICSelection,
uint8_t  TIM3_ICFilter 
) [static]

Configure the TI2 as Input.

Parameters:
TIM3_ICPolarity,:Input Capture Polarity This parameter can be one of the following values:
  • TIM3_ICPolarity_Rising: Input Capture on Rising Edge
  • TIM3_ICPolarity_Falling: Input Capture on Falling Edge
TIM3_ICSelection,:Specifies the input to be used. This parameter can be one of the following values:
  • TIM3_ICSelection_DirectTI: Input Capture mapped on the direct input
  • TIM3_ICSelection_IndirectTI: Input Capture mapped on the indirect input
  • TIM3_ICSelection_TRGI: Input Capture mapped on the Trigger Input
TIM3_ICFilter,:Specifies the Input Capture Filter. This parameter must be a value between 0x00 and 0x0F.
Return values:
None

Definition at line 2095 of file stm8l15x_tim3.c.

References IS_TIM3_IC_FILTER, IS_TIM3_IC_POLARITY, IS_TIM3_IC_SELECTION, TIM3, TIM3_ICPolarity_Falling, TIM_CCER1_CC2E, TIM_CCER1_CC2P, TIM_CCMR_CCxS, and TIM_CCMR_ICxF.

Referenced by TIM3_ICInit(), TIM3_PWMIConfig(), and TIM3_TIxExternalClockConfig().

void TIM3_BKRConfig ( TIM3_OSSIState_TypeDef  TIM3_OSSIState,
TIM3_LockLevel_TypeDef  TIM3_LockLevel,
TIM3_BreakState_TypeDef  TIM3_BreakState,
TIM3_BreakPolarity_TypeDef  TIM3_BreakPolarity,
TIM3_AutomaticOutput_TypeDef  TIM3_AutomaticOutput 
)

Configures the Break feature, dead time, Lock level, the OSSI, and the AOE(automatic output enable).

Parameters:
TIM3_OSSIState,:Off-State Selection for Idle mode states. This parameter can be one of the following values:
  • TIM3_OSSIState_Enable: Off-State Selection for Idle mode enabled
  • TIM3_OSSIState_Disable: Off-State Selection for Idle mode disabled
TIM3_LockLevel,:Lock level. This parameter can be one of the following values:
  • TIM3_LockLevel_Off: Lock option disabled
  • TIM3_LockLevel_1: Select Lock Level 1
  • TIM3_LockLevel_2: Select Lock Level 2
  • TIM3_LockLevel_3: Select Lock Level 3
TIM3_BreakState,:Break Input enable/disable . This parameter can be one of the following values:
  • TIM3_BreakState_Disable: Break State disabled (break option disabled)
  • TIM3_BreakState_Enable: Break State enabled (break option enabled)
TIM3_BreakPolarity,:Break Polarity. This parameter can be one of the following values:
  • TIM3_BreakPolarity_High: if Break, channel polarity = High
  • TIM3_BreakPolarity_Low: if Break, channel polarity = Low
TIM3_AutomaticOutput,:TIM3 AOE Bit Set/Reset . This parameter can be one of the following values:
  • TIM3_AutomaticOutput_Enable: Automatic Output option enabled
  • TIM3_AutomaticOutput_Disable: Automatic Output option disabled
Return values:
None

Definition at line 748 of file stm8l15x_tim3.c.

References IS_TIM3_AUTOMATIC_OUTPUT_STATE, IS_TIM3_BREAK_POLARITY, IS_TIM3_BREAK_STATE, IS_TIM3_LOCK_LEVEL, IS_TIM3_OSSI_STATE, and TIM3.

void TIM3_CCxCmd ( TIM3_Channel_TypeDef  TIM3_Channel,
FunctionalState  NewState 
)

Enables or disables the TIM3 Capture Compare Channel x.

Parameters:
TIM3_Channel,:Specifies the TIM3 Channel. This parameter can be one of the following values:
  • TIM3_Channel_1: Channel 1
  • TIM3_Channel_2: Channel 2
NewState,:Specifies the TIM3 Channel CCxE bit new state. This parameter can be ENABLE or DISABLE
Return values:
None

Definition at line 1068 of file stm8l15x_tim3.c.

References DISABLE, IS_FUNCTIONAL_STATE, IS_TIM3_CHANNEL, TIM3, TIM3_Channel_1, TIM_CCER1_CC1E, and TIM_CCER1_CC2E.

void TIM3_CtrlPWMOutputs ( FunctionalState  NewState)

Enables or disables the TIM3 peripheral Main Outputs.

Parameters:
NewState,:The new state of the TIM3 peripheral. This parameter can be ENABLE or DISABLE
Return values:
None

Definition at line 777 of file stm8l15x_tim3.c.

References DISABLE, IS_FUNCTIONAL_STATE, TIM3, and TIM_BKR_MOE.

void TIM3_ForcedOC1Config ( TIM3_ForcedAction_TypeDef  TIM3_ForcedAction)

Forces the TIM3 Channel1 output waveform to active or inactive level.

Parameters:
TIM3_ForcedAction,:Specifies the forced Action to be set to the output waveform. This parameter can be one of the following values:
  • TIM3_ForcedAction_Active: Output Reference is forced low
  • TIM3_ForcedAction_Inactive: Output Reference is forced high
Return values:
None

Definition at line 877 of file stm8l15x_tim3.c.

References IS_TIM3_FORCED_ACTION, TIM3, and TIM_CCMR_OCM.

void TIM3_ForcedOC2Config ( TIM3_ForcedAction_TypeDef  TIM3_ForcedAction)

Forces the TIM3 Channel2 output waveform to active or inactive level.

Parameters:
TIM3_ForcedAction,:Specifies the forced Action to be set to the output waveform. This parameter can be one of the following values:
  • TIM3_ForcedAction_Active: Output Reference is forced low
  • TIM3_ForcedAction_Inactive: Output Reference is forced high
Return values:
None

Definition at line 903 of file stm8l15x_tim3.c.

References IS_TIM3_FORCED_ACTION, TIM3, and TIM_CCMR_OCM.

void TIM3_OC1FastConfig ( FunctionalState  NewState)

Configures the TIM3 Capture Compare 1 Fast feature.

Parameters:
NewState,:The new state of the Output Compare Fast Enable bit. This parameter can be ENABLE or DISABLE
Return values:
None

Definition at line 971 of file stm8l15x_tim3.c.

References DISABLE, IS_FUNCTIONAL_STATE, TIM3, and TIM_CCMR_OCxFE.

void TIM3_OC1Init ( TIM3_OCMode_TypeDef  TIM3_OCMode,
TIM3_OutputState_TypeDef  TIM3_OutputState,
uint16_t  TIM3_Pulse,
TIM3_OCPolarity_TypeDef  TIM3_OCPolarity,
TIM3_OCIdleState_TypeDef  TIM3_OCIdleState 
)

Initializes the TIM3 Channel1 according to the specified parameters.

Parameters:
TIM3_OCMode,:Output Compare Mode This parameter can be one of the following values:
  • TIM3_OCMode_Timing: Timing (Frozen) Mode
  • TIM3_OCMode_Active: Active Mode
  • TIM3_OCMode_Inactive: Inactive Mode
  • TIM3_OCMode_Toggle: Toggle Mode
  • TIM3_OCMode_PWM1: PWM Mode 1
  • TIM3_OCMode_PWM2: PWM Mode 2
TIM3_OutputState,:Output state This parameter can be one of the following values:
  • TIM3_OutputState_Disable: Output compare State disabled (channel output disabled)
  • TIM3_OutputState_Enable: Output compare State enabled (channel output enabled)
TIM3_Pulse,:This parameter must be a value between 0x0000 and 0xFFFF.
TIM3_OCPolarity,:Polarity This parameter can be one of the following values:
  • TIM3_OCPolarity_High: Output compare polarity = High
  • TIM3_OCPolarity_Low: Output compare polarity = Low
TIM3_OCIdleState,:Output Compare Idle State This parameter can be one of the following values:
  • TIM3_OCIdleState_Reset: Output Compare Idle state = Reset
  • TIM3_OCIdleState_Set: Output Compare Idle state = Set
Return values:
None

Definition at line 572 of file stm8l15x_tim3.c.

References IS_TIM3_OC_MODE, IS_TIM3_OC_POLARITY, IS_TIM3_OCIDLE_STATE, IS_TIM3_OUTPUT_STATE, TIM3, TIM3_OCIdleState_Set, TIM3_OCPolarity_Low, TIM3_OutputState_Enable, TIM_CCER1_CC1E, TIM_CCER1_CC1P, TIM_CCMR_OCM, and TIM_OISR_OIS1.

void TIM3_OC1PolarityConfig ( TIM3_OCPolarity_TypeDef  TIM3_OCPolarity)

Configures the TIM3 Channel 1 polarity.

Parameters:
TIM3_OCPolarity,:Specifies the OC1 Polarity. This parameter can be one of the following values:
  • TIM3_OCPolarity_High: Output compare polarity = High
  • TIM3_OCPolarity_Low: Output compare polarity = Low
Return values:
None

Definition at line 1018 of file stm8l15x_tim3.c.

References IS_TIM3_OC_POLARITY, TIM3, TIM3_OCPolarity_Low, and TIM_CCER1_CC1P.

void TIM3_OC1PreloadConfig ( FunctionalState  NewState)

Enables or disables the TIM3 peripheral Preload Register on CCR1.

Parameters:
NewState,:The new state of the Capture Compare Preload register. This parameter can be ENABLE or DISABLE
Return values:
None

Definition at line 927 of file stm8l15x_tim3.c.

References DISABLE, IS_FUNCTIONAL_STATE, TIM3, and TIM_CCMR_OCxPE.

void TIM3_OC2FastConfig ( FunctionalState  NewState)

Configures the TIM3 Capture Compare 2 Fast feature.

Parameters:
NewState,:The new state of the Output Compare Fast Enable bit. This parameter can be ENABLE or DISABLE
Return values:
None

Definition at line 994 of file stm8l15x_tim3.c.

References DISABLE, IS_FUNCTIONAL_STATE, TIM3, and TIM_CCMR_OCxFE.

void TIM3_OC2Init ( TIM3_OCMode_TypeDef  TIM3_OCMode,
TIM3_OutputState_TypeDef  TIM3_OutputState,
uint16_t  TIM3_Pulse,
TIM3_OCPolarity_TypeDef  TIM3_OCPolarity,
TIM3_OCIdleState_TypeDef  TIM3_OCIdleState 
)

Initializes the TIM3 Channel2 according to the specified parameters.

Parameters:
TIM3_OCMode,:Output Compare Mode This parameter can be one of the following values:
  • TIM3_OCMode_Timing: Timing (Frozen) Mode
  • TIM3_OCMode_Active: Active Mode
  • TIM3_OCMode_Inactive: Inactive Mode
  • TIM3_OCMode_Toggle: Toggle Mode
  • TIM3_OCMode_PWM1: PWM Mode 1
  • TIM3_OCMode_PWM2: PWM Mode 2
TIM3_OutputState,:Output state This parameter can be one of the following values:
  • TIM3_OutputState_Disable: Output compare State disabled (channel output disabled)
  • TIM3_OutputState_Enable: Output compare State enabled (channel output enabled)
TIM3_Pulse,:This parameter must be a value between 0x0000 and 0xFFFF.
TIM3_OCPolarity,:Polarity This parameter can be one of the following values:
  • TIM3_OCPolarity_High: Output compare polarity = High
  • TIM3_OCPolarity_Low: Output compare polarity = Low
TIM3_OCIdleState,:Output Compare Idle State This parameter can be one of the following values:
  • TIM3_OCIdleState_Reset: Output Compare Idle state = Reset
  • TIM3_OCIdleState_Set: Output Compare Idle state = Set
Return values:
None

Definition at line 658 of file stm8l15x_tim3.c.

References IS_TIM3_OC_MODE, IS_TIM3_OC_POLARITY, IS_TIM3_OCIDLE_STATE, IS_TIM3_OUTPUT_STATE, TIM3, TIM3_OCIdleState_Set, TIM3_OCPolarity_Low, TIM3_OutputState_Enable, TIM_CCER1_CC2E, TIM_CCER1_CC2P, TIM_CCMR_OCM, and TIM_OISR_OIS2.

void TIM3_OC2PolarityConfig ( TIM3_OCPolarity_TypeDef  TIM3_OCPolarity)

Configures the TIM3 Channel 2 polarity.

Parameters:
TIM3_OCPolarity,:Specifies the OC2 Polarity. This parameter can be one of the following values:
  • TIM3_OCPolarity_High: Output compare polarity = High
  • TIM3_OCPolarity_Low: Output compare polarity = Low
Return values:
None

Definition at line 1042 of file stm8l15x_tim3.c.

References IS_TIM3_OC_POLARITY, TIM3, TIM3_OCPolarity_Low, and TIM_CCER1_CC2P.

void TIM3_OC2PreloadConfig ( FunctionalState  NewState)

Enables or disables the TIM3 peripheral Preload Register on CCR2.

Parameters:
NewState,:The new state of the Capture Compare Preload register. This parameter can be ENABLE or DISABLE
Return values:
None

Definition at line 949 of file stm8l15x_tim3.c.

References DISABLE, IS_FUNCTIONAL_STATE, TIM3, and TIM_CCMR_OCxPE.

void TIM3_SelectOCxM ( TIM3_Channel_TypeDef  TIM3_Channel,
TIM3_OCMode_TypeDef  TIM3_OCMode 
)

Selects the TIM3 Output Compare Mode.

This function disables the selected channel before changing the Output Compare Mode. User has to enable this channel using TIM3_CCxCmd and TIM3_CCxNCmd functions.

Parameters:
TIM3_Channel,:Specifies the TIM3 Channel. This parameter can be one of the following values:
  • TIM3_Channel_1: Channel 1
  • TIM3_Channel_2: Channel 2
TIM3_OCMode,:Specifies the TIM3 Output Compare Mode. This parameter can be one of the following values:
  • TIM3_OCMode_Timing: Timing (Frozen) Mode
  • TIM3_OCMode_Active: Active Mode
  • TIM3_OCMode_Inactive: Inactive Mode
  • TIM3_OCMode_Toggle: Toggle Mode
  • TIM3_OCMode_PWM1: PWM Mode 1
  • TIM3_OCMode_PWM2: PWM Mode 2
Return values:
None

Definition at line 812 of file stm8l15x_tim3.c.

References IS_TIM3_CHANNEL, IS_TIM3_OCM, TIM3, TIM3_Channel_1, TIM_CCER1_CC1E, TIM_CCER1_CC2E, and TIM_CCMR_OCM.

void TIM3_SetCompare1 ( uint16_t  Compare)

Sets the TIM3 Capture Compare1 Register value.

Parameters:
Compare,:Specifies the Capture Compare1 register new value. This parameter is between 0x0000 and 0xFFFF.
Return values:
None

Definition at line 849 of file stm8l15x_tim3.c.

References TIM3.

void TIM3_SetCompare2 ( uint16_t  Compare)

Sets the TIM3 Capture Compare2 Register value.

Parameters:
Compare,:Specifies the Capture Compare2 register new value. This parameter is between 0x0000 and 0xFFFF.
Return values:
None

Definition at line 862 of file stm8l15x_tim3.c.

References TIM3.

STM8S Firmware Library: Overview

 

 

 

For complete documentation on STM8L15x 8-bit microcontrollers platform visit www.st.com