So in the meantime I got the answers to my questions.
When CH1 triggers, the TIM3->SR register gets the value of 0x0000001f. I have looked at it in the debugger. The other channels are not even set up, so their interrupts should be disabled, right?
Well as it turns out, the channels, which are "not set up" are rather in their reset states. So the reset register settings apply to them.
It enters the TIM3_IRQHandler function and it executes the ISR of all the channels. Not only that, but it doesn't even reset the CCxIF bits when I tell it to. It just goes over the line and does nothing. According to the debugger, the TIM3->SR value remains unchanged.
Yes, it executes them, because the interrupt flags are set, no matter the settings in the TIMx->DIER register. The TIMx->DIER register serves only to set whether an interrupt is made, not if the interrupt flag sets or not. So what happened is, the CCRx registers of the unused channels were 0, and when the CNT register reached 0, they set the corresponding CCxIF interrupt flags. So in the interrupt handler I have to check not only if the interrupt flag is set for the channel, but if the channel DIER bit is enabled.
The reason all flags appeared to set at once is because in debugging mode the timer clock continued to tick, even when the code execution halted. That explains everything else that was unclear.
Answer from inaseaofsalt on Stack ExchangeVideos
Do you check for the right interrupt flag in the interrupt handler? Also keep in mind that you have to clear the flag right away.
My IRQHandler looks like this, if this is any help for you.
void TIM3_IRQHandler(void) {
if(LL_TIM_IsActiveFlag_CC1(TIM3) == 1) {
LL_TIM_ClearFlag_CC1(TIM3);
TimerCaptureCompare_Callback();
}
}
Edit:
OK as it seems, the HAL_TIM_OC_DelayElapsedCallback interrupt is only fired when the timer overflows (i. e., resets).
This means that you have to enable the overflow interrupt, as the HAL_TIM_OC_Start_IT only enables the capture/compare interrupt.
You only need to enable it before enabling the timer.
__HAL_TIM_ENABLE_IT(&tim3, TIM_IT_UPDATE );
Try to replace "TIM_IT_CC1" with "TIM_CHANNEL_1".