入,默认立即!! 参数:
TIMx,: where x can be 1 to 17 to select the TIM peripheral.
NewState,: new state of the TIMx peripheral Preload register This parameter can be: ENABLE or DISABLE.
TIM_BDTRConfig ();死区和刹车相关,待定 TIM_BDTRStructInit (); 设置所有死区刹车结构体为默认值 TIM_CCPreloadControl ();
置1后,输出可以统一通过COM事件触发换向,只对具有互补输出的位有效。 注意,一次设置一组定时器,TIMx的1~4输出口 参数:
TIMx:哪一组定时器输出口 NEWSTATE:使能还是失能 TIM_CCxCmd ();
使能比较捕获通道,前提是设置为输入模式 参数:
TIMx,: where x can be 1 to 17 except 6 and 7 to select the TIM peripheral.
TIM_Channel,: specifies the TIM Channel This parameter can be one of the following values:
TIM_Channel_1: TIM Channel 1 TIM_Channel_2: TIM Channel 2 TIM_Channel_3: TIM Channel 3 TIM_Channel_4: TIM Channel 4
TIM_CCxNCmd () 互不输入配置,没有4通道 TIM_ClearFlag (); 清楚标志位
TIMx,: where x can be 1 to 17 to select the TIM peripheral.
TIM_FLAG,: specifies the flag bit to clear. This parameter can be any combination of the following values:
TIM_FLAG_Update: TIM update Flag
TIM_FLAG_CC1: TIM Capture Compare 1 Flag TIM_FLAG_CC2: TIM Capture Compare 2 Flag TIM_FLAG_CC3: TIM Capture Compare 3 Flag TIM_FLAG_CC4: TIM Capture Compare 4 Flag TIM_FLAG_COM: TIM Commutation Flag TIM_FLAG_Trigger: TIM Trigger Flag TIM_FLAG_Break: TIM Break Flag
TIM_FLAG_CC1OF: TIM Capture Compare 1 overcapture Flag
TIM_FLAG_CC2OF: TIM Capture Compare 2 overcapture Flag TIM_FLAG_CC3OF: TIM Capture Compare 3 overcapture Flag TIM_FLAG_CC4OF: TIM Capture Compare 4 overcapture Flag
TIM_ClearITPendingBit ()
清除中断标志位,参数就是选择清除哪个中断标志位
TIMx,:
where x can be 1 to 17 to select the TIM peripheral.
TIM_IT,: specifies the pending bit to clear. This parameter can be any combination of the following values:
? ? ? ? ? ? ? ?
TIM_IT_Update: TIM1 update Interrupt source
TIM_IT_CC1: TIM Capture Compare 1 Interrupt source TIM_IT_CC2: TIM Capture Compare 2 Interrupt source TIM_IT_CC3: TIM Capture Compare 3 Interrupt source TIM_IT_CC4: TIM Capture Compare 4 Interrupt source TIM_IT_COM: TIM Commutation Interrupt source TIM_IT_Trigger: TIM Trigger Interrupt source TIM_IT_Break: TIM Break Interrupt source
TIM_ClearOC1Ref ();到TIM_ClearOC4Ref ();
清除的话,外部ETR信号不会影响输出,否则外部高信号,内部OC1REF拉低
参数:
TIMx,: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral.
TIM_OCClear,: new state of the Output Compare Clear Enable Bit. This parameter can be one of the following values:
? ?
TIM_OCClear_Enable: TIM Output clear enable TIM_OCClear_Disable: TIM Output clear disable
TIM_Cmd ();
开启定时器,定时器开始计数。 参数:
TIMx,:
where x can be 1 to 17 to select the TIMx peripheral.
NewState,: new state of the TIMx peripheral. This parameter can be: ENABLE or DISABLE.
TIM_CounterModeConfig () 时基单元的计数模式配置
TIMx,:
where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral.
TIM_CounterMode,: specifies the Counter Mode to be used This parameter can be one of the following values: ? TIM_CounterMode_Up: TIM Up Counting Mode
? TIM_CounterMode_Down: TIM Down Counting Mode
? TIM_CounterMode_CenterAligned1: TIM Center Aligned Mode1 ? TIM_CounterMode_CenterAligned2: TIM Center Aligned Mode2 ?
TIM_CounterMode_CenterAligned3: TIM Center Aligned Mode3
TIM_CtrlPWMOutputs ()
总的PWM输出允许,当设置了输出使能位,就开始输出。Main output enable
TIMx,:
where x can be 1, 8, 15, 16 or 17 to select the TIMx peripheral.
NewState,: new state of the TIM peripheral Main Outputs. This parameter can be: ENABLE or DISABLE.
TIM_DeInit (TIM1);
将该定时器的寄存器全部设为缺省值
TIM_DMACmd ()待定。。。。。 TIM_DMAConfig ()待定。。。。
TIM_EncoderInterfaceConfig ()待定。。。。编码器
TIM_ETRClockMode1Config 到 TIM_ETRClockMode2Config。。。。。
TIM_ETRConfig (); 配置外部输入的ETR信号
参数:
TIMx,: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral.
TIM_ExtTRGPrescaler,: The external Trigger Prescaler. This parameter can be one of the following values:
分频
TIM_ExtTRGPSC_OFF: ETRP Prescaler OFF.
TIM_ExtTRGPSC_DIV2: ETRP frequency divided by 2. TIM_ExtTRGPSC_DIV4: ETRP frequency divided by 4. TIM_ExtTRGPSC_DIV8: ETRP frequency divided by 8.
TIM_ExtTRGPolarity,: The external Trigger Polarity. This parameter can be one of the following values:
边沿选择
TIM_ExtTRGPolarity_Inverted: active low or falling edge active. TIM_ExtTRGPolarity_NonInverted: active high or rising edge active.
滤波
ExtTRGFilter,: External Trigger Filter. This parameter must be a value between 0x00 and 0x0F
TIM_ForcedOC1Config ();到TIM_ForcedOC4Config (); 强制输出高低电平 参数:
TIMx,:
where x can be 1 to 17 except 6 and 7 to select the TIM peripheral.
TIM_ForcedAction,: specifies the forced Action to be set to the output waveform. This parameter can be one of
the following values:
? ?
TIM_ForcedAction_Active: Force active level on OC1REF TIM_ForcedAction_InActive: Force inactive level on OC1REF.
TIM_GenerateEvent (); 软件产生事件!!
TIMx,: where x can be 1 to 17 to select the TIM peripheral.
TIM_EventSource,: specifies the event source. This parameter can be one or more of the following values:
TIM_EventSource_Update: Timer update Event source
TIM_EventSource_CC1: Timer Capture Compare 1 Event source TIM_EventSource_CC2: Timer Capture Compare 2 Event source TIM_EventSource_CC3: Timer Capture Compare 3 Event source TIM_EventSource_CC4: Timer Capture Compare 4 Event source
TIM_EventSource_COM: Timer COM event source TIM_EventSource_Trigger: Timer Trigger Event source TIM_EventSource_Break: Timer Break event source
uint16_t TIM_GetCapture1 ();到TIM_GetCapture4 (); 读CCR1,16位数据
uint16_t TIM_GetCounter (TIM1); 读计数中心值
FlagStatus TIM_GetFlagStatus(); 返回RESET和SET
TIMx,: where x can be 1 to 17 to select the TIM peripheral.
TIM_FLAG,: specifies the flag to check. This parameter can be one of the following values:
? ? ? ? ? ? ? ? ? ? ? ?
TIM_FLAG_Update: TIM update Flag
TIM_FLAG_CC1: TIM Capture Compare 1 Flag TIM_FLAG_CC2: TIM Capture Compare 2 Flag TIM_FLAG_CC3: TIM Capture Compare 3 Flag TIM_FLAG_CC4: TIM Capture Compare 4 Flag TIM_FLAG_COM: TIM Commutation Flag TIM_FLAG_Trigger: TIM Trigger Flag TIM_FLAG_Break: TIM Break Flag
TIM_FLAG_CC1OF: TIM Capture Compare 1 overcapture Flag TIM_FLAG_CC2OF: TIM Capture Compare 2 overcapture Flag TIM_FLAG_CC3OF: TIM Capture Compare 3 overcapture Flag TIM_FLAG_CC4OF: TIM Capture Compare 4 overcapture Flag
Note:
? ? ? ? ?
TIM6 and TIM7 can have only one update flag.
TIM9, TIM12 and TIM15 can have only TIM_FLAG_Update, TIM_FLAG_CC1, TIM_FLAG_CC2 or TIM_FLAG_Trigger. TIM10, TIM11, TIM13, TIM14, TIM16 and TIM17 can have TIM_FLAG_Update or TIM_FLAG_CC1. TIM_FLAG_Break is used only with TIM1, TIM8 and TIM15.
TIM_FLAG_COM is used only with TIM1, TIM8, TIM15, TIM16 and TIM17.
ITStatus TIM_GetITStatus () 获取中断状态,设置或者未设置
TIMx,:
where x can be 1 to 17 to select the TIM peripheral.
TIM_IT,: specifies the TIM interrupt source to check. This parameter can be one of the following values:
? ? ? ? ?
TIM_IT_Update: TIM update Interrupt source
TIM_IT_CC1: TIM Capture Compare 1 Interrupt source TIM_IT_CC2: TIM Capture Compare 2 Interrupt source TIM_IT_CC3: TIM Capture Compare 3 Interrupt source TIM_IT_CC4: TIM Capture Compare 4 Interrupt source