cancel
Showing results for 
Search instead for 
Did you mean: 

HTIM UIF clear from capture callback

Paolo Chiantore
Associate II
Posted on June 19, 2017 at 15:26

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 #uif
1 ACCEPTED SOLUTION

Accepted Solutions
Posted on June 19, 2017 at 18:09

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

View solution in original post

2 REPLIES 2
Posted on June 19, 2017 at 18:09

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

Posted on June 20, 2017 at 09:21

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.