[STM32F1] 这两个函数有什么区别?

[复制链接]
4737|8
 楼主| motor666 发表于 2014-5-3 10:22 | 显示全部楼层 |阅读模式
TIM_ITRxExternalClockConfig    设置 TIMx 内部触发为外部时钟模式
TIM_TIxExternalClockConfig      设置 TIMx 触发为外部时钟

都是把定时器的内部触发改为外部触发。不知有什么区别。


善水盈渊 发表于 2014-5-3 10:37 | 显示全部楼层
触发源的时钟选择 和 触发源选择
mmuuss586 发表于 2014-5-3 11:51 | 显示全部楼层
本帖最后由 mmuuss586 于 2014-5-3 11:56 编辑

楼上正解。

楼主,看下函数的原型就明白了

/**
  * @brief  Configures the TIMx Trigger as External Clock
  * @param  TIMx: where x can be 2, 3, 4, 5 or 9 to select the TIM peripheral.
  * @param  TIM_TIxExternalCLKSource: Trigger source.
  *   This parameter can be one of the following values:
  *     @arg TIM_TIxExternalCLK1Source_TI1ED: TI1 Edge Detector.
  *     @arg TIM_TIxExternalCLK1Source_TI1: Filtered Timer Input 1.
  *     @arg TIM_TIxExternalCLK1Source_TI2: Filtered Timer Input 2.
  * @param  TIM_ICPolarity: specifies the TIx Polarity.
  *   This parameter can be one of the following values:
  *     @arg TIM_ICPolarity_Rising:
  *     @arg TIM_ICPolarity_Falling:
  * @param  ICFilter : specifies the filter value.
  *   This parameter must be a value between 0x0 and 0xF.
  * @retval None
  */
void TIM_TIxExternalClockConfig(TIM_TypeDef* TIMx, uint16_t TIM_TIxExternalCLKSource,
                                uint16_t TIM_ICPolarity, uint16_t ICFilter)
{
  /* Check the parameters */
  assert_param(IS_TIM_LIST2_PERIPH(TIMx));
  assert_param(IS_TIM_IC_POLARITY(TIM_ICPolarity));
  assert_param(IS_TIM_IC_FILTER(ICFilter));
  
  /* Configure the Timer Input Clock Source */
  if (TIM_TIxExternalCLKSource == TIM_TIxExternalCLK1Source_TI2)
  {
    TI2_Config(TIMx, TIM_ICPolarity, TIM_ICSelection_DirectTI, ICFilter);
  }
  else
  {
    TI1_Config(TIMx, TIM_ICPolarity, TIM_ICSelection_DirectTI, ICFilter);
  }
  /* Select the Trigger source */
  TIM_SelectInputTrigger(TIMx, TIM_TIxExternalCLKSource);
  /* Select the External clock mode1 */
  TIMx->SMCR |= TIM_SlaveMode_External1;
}
mmuuss586 发表于 2014-5-3 11:53 | 显示全部楼层
/**
  * @brief  Configures the TIMx Internal Trigger as External Clock
  * @param  TIMx: where x can be 2, 3, 4, 5 or 9 to select the TIM peripheral.
  * @param  TIM_ITRSource: Trigger source.
  *   This parameter can be one of the following values:
  * @param  TIM_TS_ITR0: Internal Trigger 0.
  * @param  TIM_TS_ITR1: Internal Trigger 1.
  * @param  TIM_TS_ITR2: Internal Trigger 2.
  * @param  TIM_TS_ITR3: Internal Trigger 3.
  * @retval None
  */
void TIM_ITRxExternalClockConfig(TIM_TypeDef* TIMx, uint16_t TIM_InputTriggerSource)
{
  /* Check the parameters */
  assert_param(IS_TIM_LIST2_PERIPH(TIMx));
  assert_param(IS_TIM_INTERNAL_TRIGGER_SELECTION(TIM_InputTriggerSource));
  /* Select the Internal Trigger */
  TIM_SelectInputTrigger(TIMx, TIM_InputTriggerSource);
  /* Select the External clock mode1 */
  TIMx->SMCR |= TIM_SlaveMode_External1;
}
香水城 发表于 2014-5-4 09:59 | 显示全部楼层
本帖最后由 香水城 于 2014-5-4 10:05 编辑

看图说话:

TIM_ITRxExternalClockConfig,从图中标号为2的四个信号源中选择一个作为counter的时钟

TIM_TIxExternalClockConfig,从图中标号为3的三个信号源中选择一个作为counter的时钟

计数器的时钟选择.png
usst_mcclane 发表于 2014-5-4 10:03 | 显示全部楼层
版主有没有资料是将库函数与寄存器的设置对应起来的资料,本人刚开始学stm32,对于他的定时器工作流程还是不太了解,能不能给具体科普一下,在此谢过!
香水城 发表于 2014-5-4 10:08 | 显示全部楼层
usst_mcclane 发表于 2014-5-4 10:03
版主有没有资料是将库函数与寄存器的设置对应起来的资料,本人刚开始学stm32,对于他的定时器工作流程还是 ...

对于初次了解ST MCU的定时器,推荐置顶帖【ST MCU 历次培训的培训讲义】中的STM32F20xx分类下的【通用定时器_TIM.pdf】
usst_mcclane 发表于 2014-5-4 10:17 | 显示全部楼层
谢谢香主
mryw 发表于 2014-8-21 17:23 | 显示全部楼层
TIM_SelectInputTrigger 选择TIMx输入触发源,这个函数和TIM_ITRxExternalClockConfig有什么区别呢?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

176

主题

426

帖子

1

粉丝
快速回复 在线客服 返回列表 返回顶部