有几个问题请教下
1:STM32 103有支援编码器吗?
2:TIM3的TIM_CH1、 TIM_CH2是PA6、PA7
请问要如何重映射为PC6、PC7?
3:下面程式是否设定正确,使用TIM3_CH1、TIM3_CH2做编码器,
请问IO脚设PC6、PC7是否正确,编码器这样设定是否能做到向上、向下计
数
void Tcc_Encode(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);
GPIO_StructInit(&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOC, &GPIO_InitStructure);
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
// TIM_TimeBaseStructure.TIM_Period = -1;
TIM_TimeBaseStructure.TIM_Prescaler = 0;
TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up ;
TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure);
TIM_EncoderInterfaceConfig(TIM3,
TIM_EncoderMode_TI12,
TIM_ICPolarity_Falling,
TIM_ICPolarity_Falling);
TIM_SetCounter(TIM3, 0);
TIM_Cmd(TIM3, ENABLE);
}
:funk: 不好意思 刚接触STM32有很多不了解的地方,请各位指教 谢谢
|