打印
[STM32F1]

这两个函数有什么区别?

[复制链接]
4205|8
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
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;
}

使用特权

评论回复
5
香水城| | 2014-5-4 09:59 | 只看该作者
本帖最后由 香水城 于 2014-5-4 10:05 编辑

看图说话:

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

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

计数器的时钟选择.png (98.14 KB )

计数器的时钟选择.png

使用特权

评论回复
6
usst_mcclane| | 2014-5-4 10:03 | 只看该作者
版主有没有资料是将库函数与寄存器的设置对应起来的资料,本人刚开始学stm32,对于他的定时器工作流程还是不太了解,能不能给具体科普一下,在此谢过!

使用特权

评论回复
7
香水城| | 2014-5-4 10:08 | 只看该作者
usst_mcclane 发表于 2014-5-4 10:03
版主有没有资料是将库函数与寄存器的设置对应起来的资料,本人刚开始学stm32,对于他的定时器工作流程还是 ...

对于初次了解ST MCU的定时器,推荐置顶帖【ST MCU 历次培训的培训讲义】中的STM32F20xx分类下的【通用定时器_TIM.pdf】

使用特权

评论回复
8
usst_mcclane| | 2014-5-4 10:17 | 只看该作者
谢谢香主

使用特权

评论回复
9
mryw| | 2014-8-21 17:23 | 只看该作者
TIM_SelectInputTrigger 选择TIMx输入触发源,这个函数和TIM_ITRxExternalClockConfig有什么区别呢?

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

173

主题

419

帖子

1

粉丝