STM8L15x Standard Peripherals Drivers: Input Capture management functions

STM8L15x/16x Standard Peripherals Drivers

STM8L15x Standard Peripherals Drivers

Input Capture management functions

Input Capture management functions. More...

Functions

uint16_t TIM2_GetCapture1 (void)
 Gets the TIM2 Input Capture 1 value.
uint16_t TIM2_GetCapture2 (void)
 Gets the TIM2 Input Capture 2 value.
void TIM2_ICInit (TIM2_Channel_TypeDef TIM2_Channel, TIM2_ICPolarity_TypeDef TIM2_ICPolarity, TIM2_ICSelection_TypeDef TIM2_ICSelection, TIM2_ICPSC_TypeDef TIM2_ICPrescaler, uint8_t TIM2_ICFilter)
 Initializes the TIM2 peripheral according to the specified parameters.
void TIM2_PWMIConfig (TIM2_Channel_TypeDef TIM2_Channel, TIM2_ICPolarity_TypeDef TIM2_ICPolarity, TIM2_ICSelection_TypeDef TIM2_ICSelection, TIM2_ICPSC_TypeDef TIM2_ICPrescaler, uint8_t TIM2_ICFilter)
 Configures the TIM2 peripheral in PWM Input Mode according to the specified parameters.
void TIM2_SetIC1Prescaler (TIM2_ICPSC_TypeDef TIM2_IC1Prescaler)
 Sets the TIM2 Input Capture 1 prescaler.
void TIM2_SetIC2Prescaler (TIM2_ICPSC_TypeDef TIM2_IC2Prescaler)
 Sets the TIM2 Input Capture 2 prescaler.

Detailed Description

Input Capture management functions.

 ===============================================================================
                      Input Capture management functions
 ===============================================================================  
   
       ===================================================================      
              TIM2 Driver: how to use it in Input Capture Mode
       =================================================================== 
       To use the Timer in Input Capture mode, the following steps are mandatory:
       
       1. Enable TIM2 clock using CLK_PeripheralClockConfig(CLK_Peripheral_TIM2, ENABLE) function.
       
       2. Configure the TIM2 pins in input 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 = 0x0
          - Counter mode = Up counting
       
       4. Call TIM2_ICInit() to configure the desired channel to measure only 
          frequency or duty cycle of the input signal using the corresponding configuration: 
          - TIM2 Channel: TIM2_Channel
          - TIM2 Input Capture polarity: TIM2_ICPolarity
          - TIM2 Input Capture selection: TIM2_ICSelection
          - TIM2 Input Capture Prescaler: TIM2_ICPSC
          - TIM2 Input Capture filter value
          or,
          Call TIM2_PWMIConfig() to configure the desired channels with the 
          corresponding configuration and to measure the frequency and the duty
          cycle of the input signal.
          
       5. Enable global interrupts or the DMA to read the measured frequency. 
          
       6. Enable the corresponding interrupt (or DMA request) to read the captured value,
          using the function TIM2_ITConfig(TIM2_IT_CCx) (or TIM2_DMACmd(TIM2_DMASource_CCx))
       
       7. Call the TIM2_Cmd(ENABLE) function to enable the TIM2 counter.
       
       8. Use TIM2_GetCapturex() to read the captured value corresponding to
          channel x.
       
       Note1: All other functions can be used separately to modify, if needed,
          a specific feature of the Timer. 


Function Documentation

uint16_t TIM2_GetCapture1 ( void  )

Gets the TIM2 Input Capture 1 value.

Parameters:
None
Return values:
CaptureCompare 1 Register value.

Definition at line 1298 of file stm8l15x_tim2.c.

References TIM2.

uint16_t TIM2_GetCapture2 ( void  )

Gets the TIM2 Input Capture 2 value.

Parameters:
None
Return values:
CaptureCompare 2 Register value.

Definition at line 1317 of file stm8l15x_tim2.c.

References TIM2.

void TIM2_ICInit ( TIM2_Channel_TypeDef  TIM2_Channel,
TIM2_ICPolarity_TypeDef  TIM2_ICPolarity,
TIM2_ICSelection_TypeDef  TIM2_ICSelection,
TIM2_ICPSC_TypeDef  TIM2_ICPrescaler,
uint8_t  TIM2_ICFilter 
)

Initializes the TIM2 peripheral according to the specified parameters.

Parameters:
TIM2_Channel,:TIM2 Channel This parameter can be one of the following values:
  • TIM2_Channel_1: Channel 1
  • TIM2_Channel_2: Channel 2
TIM2_ICPolarity,:Input Capture Polarity This parameter can be one of the following values:
  • TIM2_ICPolarity_Rising: Input Capture on Rising Edge
  • TIM2_ICPolarity_Falling: Input Capture on Falling Edge
TIM2_ICSelection,:Input Capture Selection This parameter can be one of the following values:
  • TIM2_ICSelection_DirectTI: Input Capture mapped on the direct input
  • TIM2_ICSelection_IndirectTI: Input Capture mapped on the indirect input
  • TIM2_ICSelection_TRGI: Input Capture mapped on the Trigger Input
TIM2_ICPrescaler,:Input Capture Prescaler This parameter can be one of the following values:
  • TIM2_ICPSC_DIV1: Input Capture Prescaler = 1 (one capture every 1 event)
  • TIM2_ICPSC_DIV2: Input Capture Prescaler = 2 (one capture every 2 events)
  • TIM2_ICPSC_DIV4: Input Capture Prescaler = 4 (one capture every 4 events)
  • TIM2_ICPSC_DIV8: Input Capture Prescaler = 8 (one capture every 8 events)
TIM2_ICFilter,:This parameter must be a value between 0x00 and 0x0F.
Return values:
None

Definition at line 1178 of file stm8l15x_tim2.c.

References IS_TIM2_CHANNEL, TI1_Config(), TI2_Config(), TIM2_Channel_1, TIM2_SetIC1Prescaler(), and TIM2_SetIC2Prescaler().

void TIM2_PWMIConfig ( TIM2_Channel_TypeDef  TIM2_Channel,
TIM2_ICPolarity_TypeDef  TIM2_ICPolarity,
TIM2_ICSelection_TypeDef  TIM2_ICSelection,
TIM2_ICPSC_TypeDef  TIM2_ICPrescaler,
uint8_t  TIM2_ICFilter 
)

Configures the TIM2 peripheral in PWM Input Mode according to the specified parameters.

Parameters:
TIM2_Channel,:TIM2 Channel This parameter can be one of the following values:
  • TIM2_Channel_1: Channel 1
  • TIM2_Channel_2: Channel 2
TIM2_ICPolarity,:Input Capture Polarity This parameter can be one of the following values:
  • TIM2_ICPolarity_Rising: Input Capture on Rising Edge
  • TIM2_ICPolarity_Falling: Input Capture on Falling Edge
TIM2_ICSelection,:Input Capture Selection This parameter can be one of the following values:
  • TIM2_ICSelection_DirectTI: Input Capture mapped on the direct input
  • TIM2_ICSelection_IndirectTI: Input Capture mapped on the indirect input
  • TIM2_ICSelection_TRGI: Input Capture mapped on the Trigger Input
TIM2_ICPrescaler,:Input Capture Prescaler This parameter can be one of the following values:
  • TIM2_ICPSC_DIV1: Input Capture Prescaler = 1 (one capture every 1 event)
  • TIM2_ICPSC_DIV2: Input Capture Prescaler = 2 (one capture every 2 events)
  • TIM2_ICPSC_DIV4: Input Capture Prescaler = 4 (one capture every 4 events)
  • TIM2_ICPSC_DIV8: Input Capture Prescaler = 8 (one capture every 8 events)
Return values:
None

Definition at line 1229 of file stm8l15x_tim2.c.

References IS_TIM2_CHANNEL, TI1_Config(), TI2_Config(), TIM2_Channel_1, TIM2_ICPolarity_Falling, TIM2_ICPolarity_Rising, TIM2_ICSelection_DirectTI, TIM2_ICSelection_IndirectTI, TIM2_SetIC1Prescaler(), and TIM2_SetIC2Prescaler().

void TIM2_SetIC1Prescaler ( TIM2_ICPSC_TypeDef  TIM2_IC1Prescaler)

Sets the TIM2 Input Capture 1 prescaler.

Parameters:
TIM2_IC1Prescaler,:Specifies the Input Capture prescaler new value This parameter can be one of the following values:
  • TIM2_ICPSC_DIV1: Input Capture Prescaler = 1 (one capture every 1 event)
  • TIM2_ICPSC_DIV2: Input Capture Prescaler = 2 (one capture every 2 events)
  • TIM2_ICPSC_DIV4: Input Capture Prescaler = 4 (one capture every 4 events)
  • TIM2_ICPSC_DIV8: Input Capture Prescaler = 8 (one capture every 8 events)
Return values:
None

Definition at line 1341 of file stm8l15x_tim2.c.

References IS_TIM2_IC_PRESCALER, TIM2, and TIM_CCMR_ICxPSC.

Referenced by TIM2_ICInit(), and TIM2_PWMIConfig().

void TIM2_SetIC2Prescaler ( TIM2_ICPSC_TypeDef  TIM2_IC2Prescaler)

Sets the TIM2 Input Capture 2 prescaler.

Parameters:
TIM2_IC2Prescaler,:Specifies the Input Capture prescaler new value This parameter can be one of the following values:
  • TIM2_ICPSC_DIV1: Input Capture Prescaler = 1 (one capture every 1 event)
  • TIM2_ICPSC_DIV2: Input Capture Prescaler = 2 (one capture every 2 events)
  • TIM2_ICPSC_DIV4: Input Capture Prescaler = 4 (one capture every 4 events)
  • TIM2_ICPSC_DIV8: Input Capture Prescaler = 8 (one capture every 8 events)
Return values:
None

Definition at line 1369 of file stm8l15x_tim2.c.

References IS_TIM2_IC_PRESCALER, TIM2, and TIM_CCMR_ICxPSC.

Referenced by TIM2_ICInit(), and TIM2_PWMIConfig().

STM8S Firmware Library: Overview

 

 

 

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