Home > other >  Stm32 F103 tim3 Encoder mode model strange questions? weird
Stm32 F103 tim3 Encoder mode model strange questions? weird

Time:03-21

Stm32 tim3 Encoder mode pattern of strange questions, according to the configuration on the net here, in the tim3 STM32CubeMX configuration mode of the Encoder, the Encoder is EC11 rotation can be detected, the situation now is Encoder data can also be read, but doesn't have any display of data according to the need for change, digital entirely, according to the beating and there is no rule, please predecessors guidance,
The inside of the main program code:
 uwICValue2=LL_TIM_GetCounter (TIM3); 
LCD_ShowIntNum (73, 60, uwICValue2, sizeof (uwICValue2), RED, BLACK, 24).

TIM3 initialization code:
 void MX_TIM3_Init (void) 
{

/* the USER CODE BEGIN TIM3_Init 0 */

/* the USER CODE END TIM3_Init 0 */

LL_TIM_InitTypeDef TIM_InitStruct={0};

LL_GPIO_InitTypeDef GPIO_InitStruct={0};

Peripheral clock enable/* */
LL_APB1_GRP1_EnableClock (LL_APB1_GRP1_PERIPH_TIM3);

LL_APB2_GRP1_EnableClock (LL_APB2_GRP1_PERIPH_GPIOA);
/* * TIM3 GPIO Configuration
PA6 -- -- -- -- -- - & gt; TIM3_CH1
PA7 -- -- -- -- -- - & gt; TIM3_CH2
*/
GPIO_InitStruct. Pin=LL_GPIO_PIN_6 | LL_GPIO_PIN_7;
GPIO_InitStruct. Mode=LL_GPIO_MODE_INPUT;
GPIO_InitStruct. Pull=LL_GPIO_PULL_UP;
LL_GPIO_Init (GPIOA, & amp; GPIO_InitStruct);

/* the USER CODE BEGIN TIM3_Init 1 */

/* the USER CODE END TIM3_Init 1 */
LL_TIM_SetEncoderMode (TIM3, LL_TIM_ENCODERMODE_X4_TI12);
LL_TIM_IC_SetActiveInput (TIM3, LL_TIM_CHANNEL_CH1 LL_TIM_ACTIVEINPUT_DIRECTTI);
LL_TIM_IC_SetPrescaler (TIM3, LL_TIM_CHANNEL_CH1 LL_TIM_ICPSC_DIV1);
LL_TIM_IC_SetFilter (TIM3, LL_TIM_CHANNEL_CH1 LL_TIM_IC_FILTER_FDIV1_N2);
LL_TIM_IC_SetPolarity (TIM3, LL_TIM_CHANNEL_CH1 LL_TIM_IC_POLARITY_RISING);
LL_TIM_IC_SetActiveInput (TIM3, LL_TIM_CHANNEL_CH2 LL_TIM_ACTIVEINPUT_DIRECTTI);
LL_TIM_IC_SetPrescaler (TIM3, LL_TIM_CHANNEL_CH2 LL_TIM_ICPSC_DIV1);
LL_TIM_IC_SetFilter (TIM3, LL_TIM_CHANNEL_CH2 LL_TIM_IC_FILTER_FDIV1_N2);
LL_TIM_IC_SetPolarity (TIM3, LL_TIM_CHANNEL_CH2 LL_TIM_IC_POLARITY_RISING);
TIM_InitStruct. Prescaler=3;
TIM_InitStruct. CounterMode=LL_TIM_COUNTERMODE_UP;
TIM_InitStruct. Autoreload=100;
TIM_InitStruct. ClockDivision=LL_TIM_CLOCKDIVISION_DIV1;
LL_TIM_Init (TIM3, & amp; TIM_InitStruct);
LL_TIM_DisableARRPreload (TIM3);
LL_TIM_SetTriggerOutput (TIM3, LL_TIM_TRGO_RESET);
LL_TIM_DisableMasterSlaveMode (TIM3);
/* the USER CODE BEGIN TIM3_Init 2 */

/* the USER CODE END TIM3_Init 2 */

}

STM32CubeMX configuration

Video address:
https://v.youku.com/v_show/id_XNTEyNDM3MDE4MA==.html

CodePudding user response:

https://blog.csdn.net/wang328452854/article/details/50579832


  • Related