这个问题以前我也遇到过,是程序里面的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
您好,請選擇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);