2010-10-21 01:40 PM
Timer 1 channel 1-4 Interrupt flags are set though the interrupts are not enabled
2011-05-17 05:12 AM
Hi,
thanks for your answer. If that's the case, how would it be possible to find out which timer channel has caused the capture interrupt as there is only one interupt for four channels? best regards, Jan2011-05-17 05:12 AM
Hi jan,
I remember, when I have used some examples of timers, that in timer interrupt handler you must check only on the interrupt pending bit you have enabled. Something like this: if(TIM_GetITStatus(TIM3, TIM_IT_CC2) == SET) { } Ciao, MCU Lüfter2011-05-17 05:12 AM
2011-05-17 05:12 AM
Hi,
that's what I expected based on the reference manual too. But when I check the TIM1_SR register in the interrupt routine, all 4 interrupt flags are set to 1 although I enabled only the interrupt for channel 1. I really appreciate your help. greets, Jan2011-05-17 05:12 AM
Hi jang,
Check using the code below in timer interrupt handler. Just test the code and don't care about other capture flags. I have used the code below and it works fine in my own code. hope that helps. /* check if update flag is set */ if ((TIM1->SR & 0x00000001) != 0) { /* add your code about TIM1 update interrupt */ /* clear update flag: cleared by writing 0 */ TIM1->SR &= 0xFFFFFFFFE; } /* check if CC3 flag is set */ else if ((TIM1->SR & 0x00000008) !=0) { /* add your code relative to CC3 interrupt */ /* clear CC3 interrupt: cleared by writing 0 */ TIM1->SR & = 0xFFFFFFF7; } MCU Lüfter