TIM6 undefined interrupt reason on STM32H753I eval board
Dear experts,
I'm struggling with a strange TIM6 interrupt issue on STM32H753I.
Playing with one of Cube example projects with FreeRTOS, where TIM6 is used as HAL timer.
The original IRQ handler is very simple (and the demo works fine) :
void TIM6_DAC_IRQHandler(void)
{
HAL_TIM_IRQHandler(&TimHandle);
}But after looking at HAL_TIM_IRQHandler I wanted to "optimize" it.
Well, all good people don't use the HAL libraries at all, I know.... Anyway.
The HAL_TIM_IRQHandler checks all possible interrupt reasons before the only one possible for TIM6, the update event. So I changed the interrupt handler to this:
void TIM6_DAC_IRQHandler(void)
{
static unsigned long unkn_cnt = 0;
if (__HAL_TIM_GET_FLAG(&TimHandle, TIM_FLAG_UPDATE) != RESET)
{
if (__HAL_TIM_GET_IT_SOURCE(&TimHandle, TIM_IT_UPDATE) != RESET)
{
__HAL_TIM_CLEAR_IT(&TimHandle, TIM_IT_UPDATE);
HAL_IncTick();
return;
}
}
unkn_cnt++; //? __BKPT(6); // Unexpected interrupt reason on this vector ??
}The demo still seems to run fine, but now a lot of unknown interrupts arrive to this handler! the unkn_cnt is almost as large as tick count!
When the code falls to line 14 unkn_cnt++, the SR of TIM6 is 0.
What is really disturbing that the original code with HAL_TIM_IRQHandler() does NOT get any unknown interupts. I tested it this way:
void TIM6_DAC_IRQHandler(void)
{
uint32_t before = HAL_GetTick();
HAL_TIM_IRQHandler(&TimHandle);
if (before == HAL_GetTick()) {
__BKPT(6); // Unexpected interrupt reason on this vector ??
}
}So a breakpoint should occur whenever calling HAL_TIM_IRQHandler does not result in incrementing tick count. It does not occur.
What is missing - besides of proverbial "not broken - don't touch"?
Why the ISR is entered with TIM6 SR == 0?
Regards,
-- pa
