cancel
Showing results for 
Search instead for 
Did you mean: 

Chaining Timers (STM32F303CCT6)

JAlca
Senior

Hi all!,

I want to create a function for this:

-Generate a number of pulses (pNumber)

-With a period of seconds (nSec)

-And a Duty cycle of 150ms

For example, if I create that function "Signal(pNumber, nSec)", and then I call it:

Signal(10, 200);

I will have one pulse, of 150miliseconds, every 200 seconds, for a total of 10 pulses.

I can do it that by setting a timer in PWM, One Pulse Mode, and then control the times I start the timer by program. But I want the process more automatic, so I can start a timer and forgot for the rest of the process.

I think about Advanced timers (TIM8) for the RCR (repetition counter register). My idea is to chain TIM8 and TIM2. This way, I'll have TIM8 for count the pulses, and TIM2 to generate the pulses.

But I read using RCR the event will only is generated at the end of the count.

So, Is there a way to do this?

I think a way is to use an output from the TIM8 like External Clock Source fot TIM2, but this way I must connect the pins, and I could prefer do it without external pin connections.

1 REPLY 1

 > But I read using RCR the event will only is generated at the end of the count.

It's the *update* event which occurs only at the end of the RCR event. You still will have Compare events in every ARR cycle, so set TRGO source in CR2 to one of the Compare outputs, and set the respective channel CCR to a value between 0 and ARR (as if you'd do PWM on that channel, except you don't set actual pin to GPIO).

JW