cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F0 one timer gets affected by another timer interrupt.

GenuineDeveloper
Associate III

Hi,

I am using STM32F051R8T6 (of Discovery board). In my application I am using two timers: TIMER3 and TIMER15.

TIMER3 is used to count number of pulses. Hence, I have used it as an external clock source based timer.

TIMER15( based on internal clock source) is used to interrupt at certains ms(say 10ms) of time. I am toggling a GPIO pin inside the Timer15 interrupt, so that I can verify if the timer is right (by verifying the ON & OFF time of the GPIO pin with the configured TIMER15 time of 10ms).

The problem is, when there is no external clock source for TIMER3, the TIMER15 interrupt works fine and the GPIO pin inside the interrupt is toggled at regular timer interval. But, whenever there is an external clock source for TIMER3 , the TIMER15 is affected(i.e the GPIO toggling inside the interrupt becomes irregular).

Interrupt priority of TIMER3 is set to 1 and that of TIMER15 is 2.

Why is this happening? Where I should I check for error?

1 ACCEPTED SOLUTION

Accepted Solutions

> Interrupt priority of TIMER3 is set to 1 and that of TIMER15 is 2.

Well swap the priorities. A higher value of priority means lower prioirty (hence 0 is the highest priority for an external interrupt). Maybe your TIMER3 interrupts take too long and that's why TIMER15 is affected. Also try not to do many things in the interrupt handler, just set some flag and do the work from regular code once the flag is set.

View solution in original post

6 REPLIES 6

Is TIM3 interrupting? How is it configured?

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
GenuineDeveloper
Associate III

Yes. Basically it is being used for counting external pwm pulses. Hence, it is configured to external clock source on TI1 and it generates an interrupt when the set ARR value is reached(this is working fine).

GenuineDeveloper
Associate III

Any suggestions?

> Interrupt priority of TIMER3 is set to 1 and that of TIMER15 is 2.

Well swap the priorities. A higher value of priority means lower prioirty (hence 0 is the highest priority for an external interrupt). Maybe your TIMER3 interrupts take too long and that's why TIMER15 is affected. Also try not to do many things in the interrupt handler, just set some flag and do the work from regular code once the flag is set.

GenuineDeveloper
Associate III

Yes. I am aware of this. But, is this normal? that one timer interrupt can be affected by another?

Of course, if your TIMER3's interrupt has higher priority than TIMER15's interrupt, and it takes too long, for example 300us, and you expect your TIMER15 interrupt to work every 200us, then you'll have problems.