STM8L15x Standard Peripherals Drivers: stm8l15x_tim1.c File Reference

STM8L15x/16x Standard Peripherals Drivers

STM8L15x Standard Peripherals Drivers

stm8l15x_tim1.c File Reference

This file provides firmware functions to manage the following functionalities of the TIM1 peripheral:

  • TimeBase management
  • Output Compare management
  • Input Capture management
  • Interrupts, DMA and flags management
  • Clocks management
  • Synchronization management
  • Specific interface management.
More...
#include "stm8l15x_tim1.h"

Go to the source code of this file.

Functions

static void TI1_Config (uint8_t TIM1_ICPolarity, uint8_t TIM1_ICSelection, uint8_t TIM1_ICFilter)
 Configure the TI1 as Input.
static void TI2_Config (uint8_t TIM1_ICPolarity, uint8_t TIM1_ICSelection, uint8_t TIM1_ICFilter)
 Configure the TI2 as Input.
static void TI3_Config (uint8_t TIM1_ICPolarity, uint8_t TIM1_ICSelection, uint8_t TIM1_ICFilter)
 Configure the TI3 as Input.
static void TI4_Config (uint8_t TIM1_ICPolarity, uint8_t TIM1_ICSelection, uint8_t TIM1_ICFilter)
 Configure the TI4 as Input.
void TIM1_ARRPreloadConfig (FunctionalState NewState)
 Enables or disables TIM1 peripheral Preload register on ARR.
void TIM1_BDTRConfig (TIM1_OSSIState_TypeDef TIM1_OSSIState, TIM1_LockLevel_TypeDef TIM1_LockLevel, uint8_t TIM1_DeadTime, TIM1_BreakState_TypeDef TIM1_Break, TIM1_BreakPolarity_TypeDef TIM1_BreakPolarity, TIM1_AutomaticOutput_TypeDef TIM1_AutomaticOutput)
 Configures the Break feature, dead time, Lock level, the OSSI, and the AOE(automatic output enable).
void TIM1_CCPreloadControl (FunctionalState NewState)
 Sets or Resets the TIM1 peripheral Capture Compare Preload Control bit.
void TIM1_CCxCmd (TIM1_Channel_TypeDef TIM1_Channel, FunctionalState NewState)
 Enables or disables the TIM1 Capture Compare Channel x (x=1,..,4).
void TIM1_CCxNCmd (TIM1_Channel_TypeDef TIM1_Channel, FunctionalState NewState)
 Enables or disables the TIM1 Capture Compare Channel xN (xN=1,..,3).
void TIM1_ClearFlag (TIM1_FLAG_TypeDef TIM1_FLAG)
 Clears the TIM1�s pending flags.
void TIM1_ClearITPendingBit (TIM1_IT_TypeDef TIM1_IT)
 Clears the TIM1's interrupt pending bits.
void TIM1_ClearOC1Ref (FunctionalState NewState)
 Clears or safeguards the OC1REF signal.
void TIM1_ClearOC2Ref (FunctionalState NewState)
 Clears or safeguards the OC2REF signal.
void TIM1_ClearOC3Ref (FunctionalState NewState)
 Clears or safeguards the OC3REF signal.
void TIM1_ClearOC4Ref (FunctionalState NewState)
 Clears or safeguards the OC4REF signal.
void TIM1_Cmd (FunctionalState NewState)
 Enables or disables the TIM1 peripheral.
void TIM1_CounterModeConfig (TIM1_CounterMode_TypeDef TIM1_CounterMode)
 Specifies the TIM1 Counter Mode to be used.
void TIM1_CtrlPWMOutputs (FunctionalState NewState)
 Enables or disables the TIM1 peripheral Main Outputs.
void TIM1_DeInit (void)
 Deinitializes the TIM1 peripheral registers to their default reset values.
void TIM1_DMACmd (TIM1_DMASource_TypeDef TIM1_DMASource, FunctionalState NewState)
 Enables or disables the TIM�s DMA Requests.
void TIM1_DMAConfig (TIM1_DMABase_TypeDef TIM1_DMABase, TIM1_DMABurstLength_TypeDef TIM1_DMABurstLength)
 Configures the TIM1�s DMA interface.
void TIM1_EncoderInterfaceConfig (TIM1_EncoderMode_TypeDef TIM1_EncoderMode, TIM1_ICPolarity_TypeDef TIM1_IC1Polarity, TIM1_ICPolarity_TypeDef TIM1_IC2Polarity)
 Configures the TIM1 Encoder Interface.
void TIM1_ETRClockMode1Config (TIM1_ExtTRGPSC_TypeDef TIM1_ExtTRGPrescaler, TIM1_ExtTRGPolarity_TypeDef TIM1_ExtTRGPolarity, uint8_t ExtTRGFilter)
 Configures the TIM1 External clock Mode1.
void TIM1_ETRClockMode2Config (TIM1_ExtTRGPSC_TypeDef TIM1_ExtTRGPrescaler, TIM1_ExtTRGPolarity_TypeDef TIM1_ExtTRGPolarity, uint8_t ExtTRGFilter)
 Configures the TIM1 External clock Mode2.
void TIM1_ETRConfig (TIM1_ExtTRGPSC_TypeDef TIM1_ExtTRGPrescaler, TIM1_ExtTRGPolarity_TypeDef TIM1_ExtTRGPolarity, uint8_t ExtTRGFilter)
 Configures the TIM1 External Trigger.
void TIM1_ForcedOC1Config (TIM1_ForcedAction_TypeDef TIM1_ForcedAction)
 Forces the TIM1 Channel1 output waveform to active or inactive level.
void TIM1_ForcedOC2Config (TIM1_ForcedAction_TypeDef TIM1_ForcedAction)
 Forces the TIM1 Channel2 output waveform to active or inactive level.
void TIM1_ForcedOC3Config (TIM1_ForcedAction_TypeDef TIM1_ForcedAction)
 Forces the TIM1 Channel3 output waveform to active or inactive level.
void TIM1_GenerateEvent (TIM1_EventSource_TypeDef TIM1_EventSource)
 Configures the TIM1 event to be generated by software.
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.
uint16_t TIM1_GetCounter (void)
 Gets the TIM1 Counter value.
FlagStatus TIM1_GetFlagStatus (TIM1_FLAG_TypeDef TIM1_FLAG)
 Checks whether the specified TIM1 flag is set or not.
ITStatus TIM1_GetITStatus (TIM1_IT_TypeDef TIM1_IT)
 Checks whether the TIM1 interrupt has occurred or not.
uint16_t TIM1_GetPrescaler (void)
 Gets the TIM1 Prescaler 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_InternalClockConfig (void)
 Configures the TIM1 internal Clock.
void TIM1_ITConfig (TIM1_IT_TypeDef TIM1_IT, FunctionalState NewState)
 Enables or disables the specified TIM1 interrupts.
void TIM1_OC1FastConfig (FunctionalState NewState)
 Configures the TIM1 Capture Compare 1 Fast feature.
void TIM1_OC1Init (TIM1_OCMode_TypeDef TIM1_OCMode, TIM1_OutputState_TypeDef TIM1_OutputState, TIM1_OutputNState_TypeDef TIM1_OutputNState, uint16_t TIM1_Pulse, TIM1_OCPolarity_TypeDef TIM1_OCPolarity, TIM1_OCNPolarity_TypeDef TIM1_OCNPolarity, TIM1_OCIdleState_TypeDef TIM1_OCIdleState, TIM1_OCNIdleState_TypeDef TIM1_OCNIdleState)
 Initializes the TIM1 Channel1 according to the specified parameters.
void TIM1_OC1NPolarityConfig (TIM1_OCNPolarity_TypeDef TIM1_OCNPolarity)
 Configures the TIM1 Channel 1N polarity.
void TIM1_OC1PolarityConfig (TIM1_OCPolarity_TypeDef TIM1_OCPolarity)
 Configures the TIM1 Channel 1 polarity.
void TIM1_OC1PreloadConfig (FunctionalState NewState)
 Enables or disables the TIM1 peripheral Preload Register on CCR1.
void TIM1_OC2FastConfig (FunctionalState NewState)
 Configures the TIM1 Capture Compare 2 Fast feature.
void TIM1_OC2Init (TIM1_OCMode_TypeDef TIM1_OCMode, TIM1_OutputState_TypeDef TIM1_OutputState, TIM1_OutputNState_TypeDef TIM1_OutputNState, uint16_t TIM1_Pulse, TIM1_OCPolarity_TypeDef TIM1_OCPolarity, TIM1_OCNPolarity_TypeDef TIM1_OCNPolarity, TIM1_OCIdleState_TypeDef TIM1_OCIdleState, TIM1_OCNIdleState_TypeDef TIM1_OCNIdleState)
 Initializes the TIM1 Channel2 according to the specified parameters.
void TIM1_OC2NPolarityConfig (TIM1_OCNPolarity_TypeDef TIM1_OCNPolarity)
 Configures the TIM1 Channel 2N polarity.
void TIM1_OC2PolarityConfig (TIM1_OCPolarity_TypeDef TIM1_OCPolarity)
 Configures the TIM1 Channel 2 polarity.
void TIM1_OC2PreloadConfig (FunctionalState NewState)
 Enables or disables the TIM1 peripheral Preload Register on CCR2.
void TIM1_OC3FastConfig (FunctionalState NewState)
 Configures the TIM1 Capture Compare 3 Fast feature.
void TIM1_OC3Init (TIM1_OCMode_TypeDef TIM1_OCMode, TIM1_OutputState_TypeDef TIM1_OutputState, TIM1_OutputNState_TypeDef TIM1_OutputNState, uint16_t TIM1_Pulse, TIM1_OCPolarity_TypeDef TIM1_OCPolarity, TIM1_OCNPolarity_TypeDef TIM1_OCNPolarity, TIM1_OCIdleState_TypeDef TIM1_OCIdleState, TIM1_OCNIdleState_TypeDef TIM1_OCNIdleState)
 Initializes the TIM1 Channel3 according to the specified parameters.
void TIM1_OC3NPolarityConfig (TIM1_OCNPolarity_TypeDef TIM1_OCNPolarity)
 Configures the TIM1 Channel 3N polarity.
void TIM1_OC3PolarityConfig (TIM1_OCPolarity_TypeDef TIM1_OCPolarity)
 Configures the TIM1 Channel 3 polarity.
void TIM1_OC3PreloadConfig (FunctionalState NewState)
 Enables or disables the TIM1 peripheral Preload Register on CCR3.
void TIM1_OC4PreloadConfig (FunctionalState NewState)
 Enables or disables the TIM1 peripheral Preload Register on CCR4.
void TIM1_PrescalerConfig (uint16_t Prescaler, TIM1_PSCReloadMode_TypeDef TIM1_PSCReloadMode)
 Configures the TIM1 Prescaler.
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_SelectCCDMA (FunctionalState NewState)
 Selects the TIM1 peripheral Capture Compare DMA source.
void TIM1_SelectCOM (FunctionalState NewState)
 Selects the TIM1 peripheral Commutation event.
void TIM1_SelectHallSensor (FunctionalState NewState)
 Enables or Disables the TIM�s Hall sensor interface.
void TIM1_SelectInputTrigger (TIM1_TRGSelection_TypeDef TIM1_InputTriggerSource)
 Selects the TIM1 Input Trigger source.
void TIM1_SelectMasterSlaveMode (FunctionalState NewState)
 Sets or Resets the TIM1 Master/Slave Mode.
void TIM1_SelectOCREFClear (TIM1_OCReferenceClear_TypeDef TIM1_OCReferenceClear)
 Selects the OCReference Clear source.
void TIM1_SelectOCxM (TIM1_Channel_TypeDef TIM1_Channel, TIM1_OCMode_TypeDef TIM1_OCMode)
 Selects the TIM1 Output Compare Mode.
void TIM1_SelectOnePulseMode (TIM1_OPMode_TypeDef TIM1_OPMode)
 Selects the TIM1�s One Pulse Mode.
void TIM1_SelectOutputTrigger (TIM1_TRGOSource_TypeDef TIM1_TRGOSource)
 Selects the TIM1 Trigger Output Mode.
void TIM1_SelectSlaveMode (TIM1_SlaveMode_TypeDef TIM1_SlaveMode)
 Selects the TIM1 Slave Mode.
void TIM1_SetAutoreload (uint16_t Autoreload)
 Sets the TIM1 Autoreload Register value.
void TIM1_SetCompare1 (uint16_t Compare1)
 Sets the TIM1 Capture Compare1 Register value.
void TIM1_SetCompare2 (uint16_t Compare2)
 Sets the TIM1 Capture Compare2 Register value.
void TIM1_SetCompare3 (uint16_t Compare3)
 Sets the TIM1 Capture Compare3 Register value.
void TIM1_SetCompare4 (uint16_t Compare4)
 Sets the TIM1 Capture Compare4 Register value.
void TIM1_SetCounter (uint16_t Counter)
 Sets the TIM1 Counter Register value.
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.
void TIM1_TimeBaseInit (uint16_t TIM1_Prescaler, TIM1_CounterMode_TypeDef TIM1_CounterMode, uint16_t TIM1_Period, uint8_t TIM1_RepetitionCounter)
 Initializes the TIM1 Time Base Unit according to the specified parameters.
void TIM1_TIxExternalClockConfig (TIM1_TIxExternalCLK1Source_TypeDef TIM1_TIxExternalCLKSource, TIM1_ICPolarity_TypeDef TIM1_ICPolarity, uint8_t ICFilter)
 Configures the TIM1 Trigger as External Clock.
void TIM1_UpdateDisableConfig (FunctionalState NewState)
 Enables or Disables the TIM1 Update event.
void TIM1_UpdateRequestConfig (TIM1_UpdateSource_TypeDef TIM1_UpdateSource)
 Selects the TIM1 Update Request Interrupt source.

Detailed Description

This file provides firmware functions to manage the following functionalities of the TIM1 peripheral:

  • TimeBase management
  • Output Compare management
  • Input Capture management
  • Interrupts, DMA and flags management
  • Clocks management
  • Synchronization management
  • Specific interface management.
Author:
MCD Application Team
Version:
V1.5.0
Date:
13-May-2011
  *  
  *          ===================================================================
  *                                 How to use this driver
  *          ===================================================================
  *          This driver provides functions to configure and initialise the TIM1 
  *          peripheral
  *          These functions are split in 7 groups: 
  *   
  *          1. TIM1 TimeBase management: this group includes all needed functions 
  *             to configure the TIM Timebase unit:
  *                   - Set/Get Prescaler
  *                   - Set/Get Autoreload  
  *                   - Counter modes configuration
  *                   - Select the One Pulse mode
  *                   - Update Request Configuration
  *                   - Update Disable Configuration
  *                   - Auto-Preload Configuration 
  *                   - Enable/Disable the counter
  *                 
  *          2. TIM1 Output Compare management: this group includes all needed 
  *             functions to configure the Capture/Compare unit used in Output 
  *             compare mode: 
  *                   - Configure each channel, independently, in Output Compare mode
  *                   - Select the output compare modes
  *                   - Select the Polarities of each channel
  *                   - Set/Get the Capture/Compare register values
  *                   - Select the Output Compare Fast mode 
  *                   - Select the Output Compare Forced mode  
  *                   - Output Compare-Preload Configuration 
  *                   - Clear Output Compare Reference
  *                   - Select the OCREF Clear signal
  *                   - Enable/Disable the Capture/Compare Channels    
  *                   
  *          3. TIM1 Input Capture management: this group includes all needed 
  *             functions to configure the Capture/Compare unit used in 
  *             Input Capture mode:
  *                   - Configure each channel in input capture mode
  *                   - Configure Channel1/2 in PWM Input mode
  *                   - Set the Input Capture Prescaler
  *                   - Get the Capture/Compare values      
  *        
  *          4. TIM1 interrupts, DMA and flags management
  *                   - Enable/Disable interrupt sources
  *                   - Get flags status
  *                   - Clear flags/ Pending bits
  *                   - Enable/Disable DMA requests 
  *                   - Configure DMA burst mode
  *                   - Select CaptureCompare DMA request  
  *              
  *          5. TIM1 clocks management: this group includes all needed functions 
  *             to configure the clock controller unit:
  *                   - Select internal/External clock
  *                   - Select the external clock mode: ETR(Mode1/Mode2) or TIx
  *         
  *          6. TIM1 synchronization management: this group includes all needed 
  *             functions to configure the Synchronization unit:
  *                   - Select Input Trigger  
  *                   - Select Output Trigger  
  *                   - Select Master Slave Mode 
  *                   - ETR Configuration when used as external trigger   
  *     
  *          7. TIM1 specific interface management, this group includes all 
  *             needed functions to use the specific TIM1 interface:
  *                   - Encoder Interface Configuration
  *                   - Select Hall Sensor        
  *   
  *  
Attention:

THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.

© COPYRIGHT 2011 STMicroelectronics

Definition in file stm8l15x_tim1.c.

STM8S Firmware Library: Overview

 

 

 

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