• 已解决 73482 个问题
  • 已帮助 5993 位优秀工程师

STM32F411RE定时器编码器模式,无法检测双边沿

Ossoona 2017-08-30 浏览量:980
STM32F411RE定时器4编码器模式,不能双边沿检测,初始代码如下
 TIM_EncoderInterfaceConfig(TIM4, TIM_EncoderMode_TI1,TIM_ICPolarity_BothEdge,TIM_ICPolarity_BothEdge);
 TIM_ICStructInit(&TIM_ICInitStructure);
  TIM_ICInitStructure.TIM_ICFilter = 0;  
  TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_BothEdge;
 TIM_ICInit(TIM4, &TIM_ICInitStructure);
  TIM_ClearFlag(TIM4, TIM_FLAG_Update); 
  TIM_ITConfig(TIM4, TIM_IT_Update, ENABLE);
  TIM4->CNT = 0;
 TIM_Cmd(TIM4, ENABLE); 
0 0 收起

我来回答

上传资料:
选择文件 文件大小不超过15M(格式支持:doc、ppt、xls、pdf、zip、rar、txt)
最佳答案
  • 这个问题以前我也遇到过,是程序里面的BUG,需要改一下

    TIM4->CCER &= (uint16_t)~((uint16_t)TIM_CCER_CC1E);
    TIM4->CCMR1 |= 0x03;
    TIM4->SMCR |= (1 << 6);
    TIM4->SMCR &= ~((1 << 5) | (1 << 4));
    TIM4->CCER |= ((uint16_t)TIM_CCER_CC1E);

    详情请参考一下这篇文章http://blog.csdn.net/smallmount123/article/details/52401946

    • 发布于 2017-08-30
    • 举报
    • 评论 0
    • 0
    • 0

其他答案 数量:2
  • 您好,請選擇TI12才有雙邊觸發

     TIM_EncoderInterfaceConfig(TIM4, TIM_EncoderMode_TI1,TIM_ICPolarity_BothEdge,TIM_ICPolarity_BothEdge);

    改成

     TIM_EncoderInterfaceConfig(TIM4, TIM_EncoderMode_TII2,TIM_ICPolarity_BothEdge,TIM_ICPolarity_BothEdge);

    • 发布于2017-08-31
    • 举报
    • 评论 0
    • 0
    • 0

电子老工程师 回复了  :对插端:BACC63CU11-35PN 回复

相关问题

问题达人换一批

STM32F411RE定时器编码器模式,无法检测双边沿