2022-02-08 06:10 PM
Hi, I'm pretty new to stm32.
My goal is to use HAL_TIM_Encoder_Start() , HAL_TIM_Encoder_Start_DMA(), HAL_TIM_Encoder_Start_IT() commands from Hal library.
I have the stm32f407 Discovery board.
in polling mode
//-------------------------------------------------------------------------------------
HAL_TIM_Encoder_Start(&htim2, TIM_CHANNEL_ALL);
//-------------------------------------------------------------------------------------
while (1)
{
encoder_value=__HAL_TIM_GET_COUNTER(&htim2);
}
in my code like everything works fine.
now i am trying to start it in interrupt mode.
HAL_TIM_Encoder_Start_IT(&htim2, TIM_CHANNEL_ALL);
TIM2_IRQHandler(void)
TIM2_IRQHandler(void)
{
HAL_TIM_IRQHandler(&htim2);
uint32_t encoder_value=0;
encoder_value=__HAL_TIM_GET_COUNTER(&htim2);
}
I know we have to write it inside the function but I couldn't get the values somehow.
Any Help?
2022-02-08 11:14 PM
> HAL_TIM_Encoder_Start_IT(&htim2, TIM_CHANNEL_ALL);
Check return value.
Read out and check/post TIM registers content.
Check if you have enabled respective interrupt(s) in NVIC, if the ISR is properly named etc.
JW
2022-02-09 12:35 AM
The timer interrupt is activated in case of overflow. You can try reading with DMA.