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 TIM3_GetCapture1 (void)
 Gets the TIM3 Input Capture 1 value.
uint16_t TIM3_GetCapture2 (void)
 Gets the TIM3 Input Capture 2 value.
void TIM3_ICInit (TIM3_Channel_TypeDef TIM3_Channel, TIM3_ICPolarity_TypeDef TIM3_ICPolarity, TIM3_ICSelection_TypeDef TIM3_ICSelection, TIM3_ICPSC_TypeDef TIM3_ICPrescaler, uint8_t TIM3_ICFilter)
 Initializes the TIM3 peripheral according to the specified parameters.
void TIM3_PWMIConfig (TIM3_Channel_TypeDef TIM3_Channel, TIM3_ICPolarity_TypeDef TIM3_ICPolarity, TIM3_ICSelection_TypeDef TIM3_ICSelection, TIM3_ICPSC_TypeDef TIM3_ICPrescaler, uint8_t TIM3_ICFilter)
 Configures the TIM3 peripheral in PWM Input Mode according to the specified parameters.
void TIM3_SetIC1Prescaler (TIM3_ICPSC_TypeDef TIM3_IC1Prescaler)
 Sets the TIM3 Input Capture 1 prescaler.
void TIM3_SetIC2Prescaler (TIM3_ICPSC_TypeDef TIM3_IC2Prescaler)
 Sets the TIM3 Input Capture 2 prescaler.

Detailed Description

Input Capture management functions.

 ===============================================================================
                      Input Capture management functions
 ===============================================================================  
   
       ===================================================================      
              TIM3 Driver: how to use it in Input Capture Mode
       =================================================================== 
       To use the Timer in Input Capture mode, the following steps are mandatory:
       
       1. Enable TIM3 clock using CLK_PeripheralClockConfig(CLK_Peripheral_TIM3, ENABLE) function.
       
       2. Configure the TIM3 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 TIM3_ICInit() to configure the desired channel to measure only 
          frequency or duty cycle of the input signal using the corresponding configuration: 
          - TIM3 Channel: TIM3_Channel
          - TIM3 Input Capture polarity: TIM3_ICPolarity
          - TIM3 Input Capture selection: TIM3_ICSelection
          - TIM3 Input Capture Prescaler: TIM3_ICPSC
          - TIM3 Input Capture filter value
          or,
          Call TIM3_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 TIM3_ITConfig(TIM3_IT_CCx) (or TIM3_DMACmd(TIM3_DMASource_CCx))
       
       7. Call the TIM3_Cmd(ENABLE) function to enable the TIM3 counter.
       
       8. Use TIM3_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 TIM3_GetCapture1 ( void  )

Gets the TIM3 Input Capture 1 value.

Parameters:
None
Return values:
CaptureCompare 1 Register value.

Definition at line 1298 of file stm8l15x_tim3.c.

References TIM3.

uint16_t TIM3_GetCapture2 ( void  )

Gets the TIM3 Input Capture 2 value.

Parameters:
None
Return values:
CaptureCompare 2 Register value.

Definition at line 1317 of file stm8l15x_tim3.c.

References TIM3.

void TIM3_ICInit ( TIM3_Channel_TypeDef  TIM3_Channel,
TIM3_ICPolarity_TypeDef  TIM3_ICPolarity,
TIM3_ICSelection_TypeDef  TIM3_ICSelection,
TIM3_ICPSC_TypeDef  TIM3_ICPrescaler,
uint8_t  TIM3_ICFilter 
)

Initializes the TIM3 peripheral according to the specified parameters.

Parameters:
TIM3_Channel,:TIM3 Channel This parameter can be one of the following values:
  • TIM3_Channel_1: Channel 1
  • TIM3_Channel_2: Channel 2
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,:Input Capture Selection 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_ICPrescaler,:Input Capture Prescaler This parameter can be one of the following values:
  • TIM3_ICPSC_DIV1: Input Capture Prescaler = 1 (one capture every 1 event)
  • TIM3_ICPSC_DIV2: Input Capture Prescaler = 2 (one capture every 2 events)
  • TIM3_ICPSC_DIV4: Input Capture Prescaler = 4 (one capture every 4 events)
  • TIM3_ICPSC_DIV8: Input Capture Prescaler = 8 (one capture every 8 events)
TIM3_ICFilter,:This parameter must be a value between 0x00 and 0x0F.
Return values:
None

Definition at line 1178 of file stm8l15x_tim3.c.

References IS_TIM3_CHANNEL, TI1_Config(), TI2_Config(), TIM3_Channel_1, TIM3_SetIC1Prescaler(), and TIM3_SetIC2Prescaler().

void TIM3_PWMIConfig ( TIM3_Channel_TypeDef  TIM3_Channel,
TIM3_ICPolarity_TypeDef  TIM3_ICPolarity,
TIM3_ICSelection_TypeDef  TIM3_ICSelection,
TIM3_ICPSC_TypeDef  TIM3_ICPrescaler,
uint8_t  TIM3_ICFilter 
)

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

Parameters:
TIM3_Channel,:TIM3 Channel This parameter can be one of the following values:
  • TIM3_Channel_1: Channel 1
  • TIM3_Channel_2: Channel 2
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,:Input Capture Selection 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_ICPrescaler,:Input Capture Prescaler This parameter can be one of the following values:
  • TIM3_ICPSC_DIV1: Input Capture Prescaler = 1 (one capture every 1 event)
  • TIM3_ICPSC_DIV2: Input Capture Prescaler = 2 (one capture every 2 events)
  • TIM3_ICPSC_DIV4: Input Capture Prescaler = 4 (one capture every 4 events)
  • TIM3_ICPSC_DIV8: Input Capture Prescaler = 8 (one capture every 8 events)
Return values:
None

Definition at line 1229 of file stm8l15x_tim3.c.

References IS_TIM3_CHANNEL, TI1_Config(), TI2_Config(), TIM3_Channel_1, TIM3_ICPolarity_Falling, TIM3_ICPolarity_Rising, TIM3_ICSelection_DirectTI, TIM3_ICSelection_IndirectTI, TIM3_SetIC1Prescaler(), and TIM3_SetIC2Prescaler().

void TIM3_SetIC1Prescaler ( TIM3_ICPSC_TypeDef  TIM3_IC1Prescaler)

Sets the TIM3 Input Capture 1 prescaler.

Parameters:
TIM3_IC1Prescaler,:Specifies the Input Capture prescaler new value This parameter can be one of the following values:
  • TIM3_ICPSC_DIV1: Input Capture Prescaler = 1 (one capture every 1 event)
  • TIM3_ICPSC_DIV2: Input Capture Prescaler = 2 (one capture every 2 events)
  • TIM3_ICPSC_DIV4: Input Capture Prescaler = 4 (one capture every 4 events)
  • TIM3_ICPSC_DIV8: Input Capture Prescaler = 8 (one capture every 8 events)
Return values:
None

Definition at line 1341 of file stm8l15x_tim3.c.

References IS_TIM3_IC_PRESCALER, TIM3, and TIM_CCMR_ICxPSC.

Referenced by TIM3_ICInit(), and TIM3_PWMIConfig().

void TIM3_SetIC2Prescaler ( TIM3_ICPSC_TypeDef  TIM3_IC2Prescaler)

Sets the TIM3 Input Capture 2 prescaler.

Parameters:
TIM3_IC2Prescaler,:Specifies the Input Capture prescaler new value This parameter can be one of the following values:
  • TIM3_ICPSC_DIV1: Input Capture Prescaler = 1 (one capture every 1 event)
  • TIM3_ICPSC_DIV2: Input Capture Prescaler = 2 (one capture every 2 events)
  • TIM3_ICPSC_DIV4: Input Capture Prescaler = 4 (one capture every 4 events)
  • TIM3_ICPSC_DIV8: Input Capture Prescaler = 8 (one capture every 8 events)
Return values:
None

Definition at line 1369 of file stm8l15x_tim3.c.

References IS_TIM3_IC_PRESCALER, TIM3, and TIM_CCMR_ICxPSC.

Referenced by TIM3_ICInit(), and TIM3_PWMIConfig().

STM8S Firmware Library: Overview

 

 

 

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