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 TIM1_GetCapture1 (void)
 Gets the TIM1 Input Capture 1 value.
uint16_t TIM1_GetCapture2 (void)
 Gets the TIM1 Input Capture 2 value.
uint16_t TIM1_GetCapture3 (void)
 Gets the TIM1 Input Capture 3 value.
uint16_t TIM1_GetCapture4 (void)
 Gets the TIM1 Input Capture 4 value.
void TIM1_ICInit (TIM1_Channel_TypeDef TIM1_Channel, TIM1_ICPolarity_TypeDef TIM1_ICPolarity, TIM1_ICSelection_TypeDef TIM1_ICSelection, TIM1_ICPSC_TypeDef TIM1_ICPrescaler, uint8_t TIM1_ICFilter)
 Initializes the TIM1 peripheral according to the specified parameters.
void TIM1_PWMIConfig (TIM1_Channel_TypeDef TIM1_Channel, TIM1_ICPolarity_TypeDef TIM1_ICPolarity, TIM1_ICSelection_TypeDef TIM1_ICSelection, TIM1_ICPSC_TypeDef TIM1_ICPrescaler, uint8_t TIM1_ICFilter)
 Configures the TIM1 peripheral in PWM Input Mode according to the specified parameters.
void TIM1_SetIC1Prescaler (TIM1_ICPSC_TypeDef TIM1_IC1Prescaler)
 Sets the TIM1 Input Capture 1 prescaler.
void TIM1_SetIC2Prescaler (TIM1_ICPSC_TypeDef TIM1_IC2Prescaler)
 Sets the TIM1 Input Capture 2 prescaler.
void TIM1_SetIC3Prescaler (TIM1_ICPSC_TypeDef TIM1_IC3Prescaler)
 Sets the TIM1 Input Capture 3 prescaler.
void TIM1_SetIC4Prescaler (TIM1_ICPSC_TypeDef TIM1_IC4Prescaler)
 Sets the TIM1 Input Capture 4 prescaler.

Detailed Description

Input Capture management functions.

 ===============================================================================
                      Input Capture management functions
 ===============================================================================  
   
       ===================================================================      
              TIM1 Driver: how to use it in Input Capture Mode
       =================================================================== 
       To use the Timer in Input Capture mode, the following steps are mandatory:
       
       1. Enable TIM1 clock using CLK_PeripheralClockConfig(CLK_Peripheral_TIM1, ENABLE) function.
       
       2. Configure the TIM1 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 = 0x0000
          - Counter mode = Up counting
       
       4. Call TIM1_ICInit() to configure the desired channel to measure only 
          frequency or duty cycle of the input signal using the corresponding configuration: 
          - TIM1 Channel: TIM1_Channel
          - TIM1 Input Capture polarity: TIM1_ICPolarity
          - TIM1 Input Capture selection: TIM1_ICSelection
          - TIM1 Input Capture Prescaler: TIM1_ICPSC
          - TIM1 Input Capture filter value
          or,
          Call TIM1_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 TIM1_ITConfig(TIM1_IT_CCx) (or TIM1_DMACmd(TIM1_DMASource_CCx))
       
       7. Call the TIM1_Cmd(ENABLE) function to enable the TIM1 counter.
       
       8. Use TIM1_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 TIM1_GetCapture1 ( void  )

Gets the TIM1 Input Capture 1 value.

Parameters:
None
Return values:
CaptureCompare 1 Register value.

Definition at line 1797 of file stm8l15x_tim1.c.

References TIM1.

uint16_t TIM1_GetCapture2 ( void  )

Gets the TIM1 Input Capture 2 value.

Parameters:
None
Return values:
CaptureCompare 2 Register value.

Definition at line 1818 of file stm8l15x_tim1.c.

References TIM1.

uint16_t TIM1_GetCapture3 ( void  )

Gets the TIM1 Input Capture 3 value.

Parameters:
None
Return values:
CaptureCompare 3 Register value.

Definition at line 1839 of file stm8l15x_tim1.c.

References TIM1.

uint16_t TIM1_GetCapture4 ( void  )

Gets the TIM1 Input Capture 4 value.

Parameters:
None
Return values:
CaptureCompare 4 Register value.

Definition at line 1859 of file stm8l15x_tim1.c.

References TIM1.

void TIM1_ICInit ( TIM1_Channel_TypeDef  TIM1_Channel,
TIM1_ICPolarity_TypeDef  TIM1_ICPolarity,
TIM1_ICSelection_TypeDef  TIM1_ICSelection,
TIM1_ICPSC_TypeDef  TIM1_ICPrescaler,
uint8_t  TIM1_ICFilter 
)

Initializes the TIM1 peripheral according to the specified parameters.

Parameters:
TIM1_Channelspecifies the input capture channel This parameter can be one of the following values:
  • TIM1_Channel_1: TIM1 Channel1
  • TIM1_Channel_2: TIM1 Channel2
  • TIM1_Channel_3: TIM1 Channel3
  • TIM1_Channel_4: TIM1 Channel4
TIM1_ICPolarityspecifies the Input capture polarity This parameter can be one of the following values:
  • TIM1_ICPolarity_Rising: Input capture polarity rising
  • TIM1_ICPolarity_Falling: Input capture polarity falling
TIM1_ICSelectionspecifies the Input capture source selection This parameter can be one of the following values:
  • TIM1_ICSelection_DirectTI: TIM1 Input x is selected to be connected to ICx.
  • TIM1_ICSelection_IndirectTI: TIM1 Input x is selected to be connected to ICy.
  • TIM1_ICSelection_TRGI: TIM1 Input x is selected to be connected to the TRGI
TIM1_ICPrescalerspecifies the Input capture Prescaler This parameter can be one of the following values:
  • TIM1_ICPSC_DIV1: Input Capture Prescaler = 1 (one capture every 1 event)
  • TIM1_ICPSC_DIV2: Input Capture Prescaler = 2 (one capture every 2 events)
  • TIM1_ICPSC_DIV4: Input Capture Prescaler = 4 (one capture every 4 events)
  • TIM1_ICPSC_DIV8: Input Capture Prescaler = 8 (one capture every 8 events)
TIM1_ICFilterspecifies the Input capture filter value.
Note:
If the channel 3 is selected the TIM1_ICSelection_IndirectTI parameter is forbidden.
If the channel 4 is selected the TIM1_ICSelection_DirectTI parameter is forbidden.
Return values:
None

Definition at line 1658 of file stm8l15x_tim1.c.

References IS_TIM1_CHANNEL, IS_TIM1_IC_FILTER, IS_TIM1_IC_POLARITY, IS_TIM1_IC_PRESCALER, IS_TIM1_IC_SELECTION, TI1_Config(), TI2_Config(), TI3_Config(), TI4_Config(), TIM1_Channel_1, TIM1_Channel_2, TIM1_Channel_3, TIM1_SetIC1Prescaler(), TIM1_SetIC2Prescaler(), TIM1_SetIC3Prescaler(), and TIM1_SetIC4Prescaler().

void TIM1_PWMIConfig ( TIM1_Channel_TypeDef  TIM1_Channel,
TIM1_ICPolarity_TypeDef  TIM1_ICPolarity,
TIM1_ICSelection_TypeDef  TIM1_ICSelection,
TIM1_ICPSC_TypeDef  TIM1_ICPrescaler,
uint8_t  TIM1_ICFilter 
)

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

Parameters:
TIM1_Channelspecifies the input capture channel This parameter can be one of the following values:
  • TIM1_Channel_1: TIM1 Channel1
  • TIM1_Channel_2: TIM1 Channel2
TIM1_ICPolarityspecifies the Input capture polarity This parameter can be one of the following values:
  • TIM1_ICPolarity_Rising: Input capture polarity rising
  • TIM1_ICPolarity_Falling: Input capture polarity falling
TIM1_ICSelectionspecifies the Input capture source selection This parameter can be one of the following values:
  • TIM1_ICSelection_DirectTI: TIM1 Input x is selected to be connected to ICx.
  • TIM1_ICSelection_IndirectTI: TIM1 Input x is selected to be connected to ICy.
  • TIM1_ICSelection_TRGI: TIM1 Input x is selected to be connected to the TRGI
TIM1_ICPrescalerspecifies the Input capture Prescaler This parameter can be one of the following values:
  • TIM1_ICPSC_DIV1: Input Capture Prescaler = 1 (one capture every 1 event)
  • TIM1_ICPSC_DIV2: Input Capture Prescaler = 2 (one capture every 2 events)
  • TIM1_ICPSC_DIV4: Input Capture Prescaler = 4 (one capture every 4 events)
  • TIM1_ICPSC_DIV8: Input Capture Prescaler = 8 (one capture every 8 events)
TIM1_ICFilterspecifies the Input capture filter value.
Return values:
None

Definition at line 1727 of file stm8l15x_tim1.c.

References IS_TIM1_IC_POLARITY, IS_TIM1_IC_PRESCALER, IS_TIM1_IC_SELECTION, IS_TIM1_PWMI_CHANNEL, TI1_Config(), TI2_Config(), TIM1_Channel_1, TIM1_ICPolarity_Falling, TIM1_ICPolarity_Rising, TIM1_ICSelection_DirectTI, TIM1_ICSelection_IndirectTI, TIM1_SetIC1Prescaler(), and TIM1_SetIC2Prescaler().

void TIM1_SetIC1Prescaler ( TIM1_ICPSC_TypeDef  TIM1_IC1Prescaler)

Sets the TIM1 Input Capture 1 prescaler.

Parameters:
TIM1_IC1Prescalerspecifies the Input Capture prescaler new value This parameter can be one of the following values:
  • TIM1_ICPSC_DIV1: Input Capture Prescaler = 1 (one capture every 1 event)
  • TIM1_ICPSC_DIV2: Input Capture Prescaler = 2 (one capture every 2 events)
  • TIM1_ICPSC_DIV4: Input Capture Prescaler = 4 (one capture every 4 events)
  • TIM1_ICPSC_DIV8: Input Capture Prescaler = 8 (one capture every 8 events)
Return values:
None

Definition at line 1884 of file stm8l15x_tim1.c.

References IS_TIM1_IC_PRESCALER, TIM1, and TIM1_CCMR_ICxPSC.

Referenced by TIM1_ICInit(), and TIM1_PWMIConfig().

void TIM1_SetIC2Prescaler ( TIM1_ICPSC_TypeDef  TIM1_IC2Prescaler)

Sets the TIM1 Input Capture 2 prescaler.

Parameters:
TIM1_IC2Prescalerspecifies the Input Capture prescaler new value This parameter can be one of the following values:
  • TIM1_ICPSC_DIV1: Input Capture Prescaler = 1 (one capture every 1 event)
  • TIM1_ICPSC_DIV2: Input Capture Prescaler = 2 (one capture every 2 events)
  • TIM1_ICPSC_DIV4: Input Capture Prescaler = 4 (one capture every 4 events)
  • TIM1_ICPSC_DIV8: Input Capture Prescaler = 8 (one capture every 8 events)
Return values:
None

Definition at line 1903 of file stm8l15x_tim1.c.

References IS_TIM1_IC_PRESCALER, TIM1, and TIM1_CCMR_ICxPSC.

Referenced by TIM1_ICInit(), and TIM1_PWMIConfig().

void TIM1_SetIC3Prescaler ( TIM1_ICPSC_TypeDef  TIM1_IC3Prescaler)

Sets the TIM1 Input Capture 3 prescaler.

Parameters:
TIM1_IC3Prescalerspecifies the Input Capture prescaler new value This parameter can be one of the following values:
  • TIM1_ICPSC_DIV1: Input Capture Prescaler = 1 (one capture every 1 event)
  • TIM1_ICPSC_DIV2: Input Capture Prescaler = 2 (one capture every 2 events)
  • TIM1_ICPSC_DIV4: Input Capture Prescaler = 4 (one capture every 4 events)
  • TIM1_ICPSC_DIV8: Input Capture Prescaler = 8 (one capture every 8 events)
Return values:
None

Definition at line 1922 of file stm8l15x_tim1.c.

References IS_TIM1_IC_PRESCALER, TIM1, and TIM1_CCMR_ICxPSC.

Referenced by TIM1_ICInit().

void TIM1_SetIC4Prescaler ( TIM1_ICPSC_TypeDef  TIM1_IC4Prescaler)

Sets the TIM1 Input Capture 4 prescaler.

Parameters:
TIM1_IC4Prescalerspecifies the Input Capture prescaler new value This parameter can be one of the following values:
  • TIM1_ICPSC_DIV1: Input Capture Prescaler = 1 (one capture every 1 event)
  • TIM1_ICPSC_DIV2: Input Capture Prescaler = 2 (one capture every 2 events)
  • TIM1_ICPSC_DIV4: Input Capture Prescaler = 4 (one capture every 4 events)
  • TIM1_ICPSC_DIV8: Input Capture Prescaler = 8 (one capture every 8 events)
Return values:
None

Definition at line 1942 of file stm8l15x_tim1.c.

References IS_TIM1_IC_PRESCALER, TIM1, and TIM1_CCMR_ICxPSC.

Referenced by TIM1_ICInit().

STM8S Firmware Library: Overview

 

 

 

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