2017-06-19 06:26 AM
On a STM32 F777 I am configuring TIM4 to read Hall sensors (HAL_TIMEx_HallSensor_Init).
I have enabled capture interrupt and in capture callback (which is triggered at every Hall event as expected) I am clearing UIF flag (i.e. timer overflow flag).
The issue is that everytime the capture callback is triggered UIF flag is always found to be one even if I measure Hall events faster than timer overflow (which is expected every 32.7 ms). With reference to the attached figure: code never breaks in line 282.
Any hint appreciated.
#callback #tim #clear #uifSolved! Go to Solution.
2017-06-19 09:09 AM
HAL_TIMEx_HallSensor_Init sets SMS to Reset on every edge
/* Use the TIM_TS_TI1F_ED signal to reset the TIM counter each edge detection */
htim->Instance->SMCR &= ~TIM_SMCR_SMS; htim->Instance->SMCR |= TIM_SLAVEMODE_RESET;Slave reset causes the update flag to be set:
100: Reset Mode - Rising edge of the selected trigger input (TRGI) reinitializes the counter
and generates an update of the registers.JW
2017-06-19 09:09 AM
HAL_TIMEx_HallSensor_Init sets SMS to Reset on every edge
/* Use the TIM_TS_TI1F_ED signal to reset the TIM counter each edge detection */
htim->Instance->SMCR &= ~TIM_SMCR_SMS; htim->Instance->SMCR |= TIM_SLAVEMODE_RESET;Slave reset causes the update flag to be set:
100: Reset Mode - Rising edge of the selected trigger input (TRGI) reinitializes the counter
and generates an update of the registers.JW
2017-06-20 02:21 AM
Thank you Jan, you are right.
The solution in my use case is to set TIM4_CR1.URS bit so that UIF flag is set just by overflow events, while slave generated update events will be ignored.