|
已经实现
/* TIM4 clock enable */ RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4, ENABLE);
/*GPIOA Configuration: TIM4 channel 1 and 2 */ /* GPIOB Configuration PB6 / PB7*/ 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(GPIOB, &GPIO_InitStructure);
//TIM_DeInit(TIM4);//初始化 TIM_EncoderInterfaceConfig(TIM4, TIM_EncoderMode_TI12,TIM_ICPolarity_Rising, TIM_ICPolarity_Rising);// Configures the encoder mode TI1 for TIM4 /* Enables the TIM2 counter */ TIM_Cmd(TIM4, ENABLE);
//读取角度 TIMCounter = (u32)TIM_GetCounter(TIM4);
只是现在发现,转动快的时候会丢角度.不知道这个玩意支持多块的编码器转动速度.
|
|