cancel
Showing results for 
Search instead for 
Did you mean: 

CC Timer Interrupt (STM32F102RBT6)

jmorton
Associate II
Posted on December 16, 2011 at 19:19

Using a general purpose timer (TIM3), with a constant frequency I would like to be able to occasionally generate an interrupt on CC3 using a variable count for CCR3.  

I do not want to generate a PWM signal or change the state of the output.  I just would like to use the CC3 interrupt simply for timing.

I have the timer base for TIM3 configured as desired, but can't correctly setup the CC3 channel.

My interrupt (TIM_IT_CC3) is firing when TIM3 rolls over, not when the CCR3 value is reached.

Using the driver, I have set the mode to TIM_OCMode_Timing and then set the pulse value to my desired time interval.

What am I missing?

Thanks.

#timer #interrupt #tim #doh
2 REPLIES 2
Posted on December 16, 2011 at 19:33

Seems like a reasonably viable method, along the lines of the example

\STM32F10xFWLib\Examples\TIM\TimeBase\main.c

The example makes the assumption of a full 16-bit count, and keeps advancing the various CCR values and toggling GPIO to demonstrate the interrupts working.

You'd have to make sure you didn't advance the CCR value beyond the period of the counter if you had a shorter count.

Maybe you fell down in the implementation, but I have nothing to go on.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jmorton
Associate II
Posted on December 16, 2011 at 19:50

Yeah I was not incrementing the CCR register.

Not sure how I missed that minor detail.....

Thanks.