2020-04-21 07:44 AM
STM32F103 MCU , CubeMX generated code for Atollic True studio.
TIM1 configured in Combine Channel -> Encoder Mode , User Parameter ->EncoderMode -> Ti1 and Ti2 , NVIC Settings -> TIM1 Update Interrupt enabled.
HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) - method implemented in main.c
contains only a GPIO LED toggle
main() method contain timer init generated code and timer start call
HAL_TIM_Encoder_Start_IT(&htim1,TIM_CHANNEL_ALL);
Also contains methods to print encoder counts.
As the encoder is turned, encoder counts are printed, but when the Counter period ARR - value over flows the interrupt is not fired.
Is period elapsed the correct call back? do i need to do something more?
I tried with TIM4 similar setting enabled global interrupt, but same results, encoder count is printed but overflow / underflow interrupt is no called.
Any suggestions?
Regards
Samit
Solved! Go to Solution.
2020-04-22 02:32 AM
it seems that if both HAL_TIM_Base_Start_IT() and HAL_TIM_Encoder_Start() calls.are ... invoked the update interrupts are fired..... but in a very uncontrolled manner....
here is the thread that i followed https://community.st.com/s/question/0D50X00009XkXgZSAV/timer-encoder-overflow-interrupt
Let me try a few combinations and get back
2020-04-22 07:41 AM
It seems that for update interrupt to work in encoder mode as of CubeMX 5.6 , TrueStudio 9.3.0 STMCube F1xx package 1.8.
HAL_TIM_Base_Start_IT() needs to be invoked before HAL_TIM_Encoder_Start(). to get update interrupts working.... may be this is just a hack
Only HAL_TIM_Encoder_Start()_IT() does not seem to setup update interrupts correctly....
may be some time I can try and see what happens if HAL_TIM_Base_Start_IT() is used with HAL_TIM_Encoder_Start()_IT()
2020-04-23 09:27 PM
After tring to wrap my head around a couple of hundred pages from RM0008 (Reference Manual STM32F1xx) and Datasheet and digging into the HAL code and HAL CHM files in Cube packages. It seems that the update event is configured by HAL_TIM_Base_Start_IT and the HAL_TIM_Encoder_Start_IT configures only the CC interrupts which is related to change of count......
So if you want update IT in encoder mode you got to start TIM_Base with IT.