Skip to main content
unternehmen
Associate II
September 20, 2019
Question

Is it possible to cascade the repitition counters from timer 1 and timer 8 to a 16 bit counter?

  • September 20, 2019
  • 7 replies
  • 1894 views

The value of the repetition counter can only be 255 maximum. However, I have to generate over 255 pulses, which I must be able to adjust. Is there still another possibility to generate 65536 pulses without using interrupts?

This topic has been closed for replies.

7 replies

Tesla DeLorean
Guru
September 21, 2019

The H7 parts have a 16-bit repetition count as I recall.

Other things for pulse trains could be a pattern buffer, driving GPIO, or filling CCRx with 50/50 numbers, and final with 0 to turn off

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
unternehmen
Associate II
September 21, 2019

Thanks for the answer but I have only one SM32F407 available and need something that I throw once, but which runs alone in the background. I have to do other fast things at this time. In addition, in the worst case, I have to change the PWM at every startup.

I almost suspect that I have to somehow count the pulse (possibly with another timer) and before the repetition counter goes to 0, write a new value in the RCR.

waclawek.jan
Super User
September 21, 2019

You ought to use the timer's linking.

You can set one linker to on-pulse with repeat N times, and set it to be slave triggered from other timer, which too runs in one-time with repetition M and with period Nx the first timer period. The number of pulses will be restricted to those which has no prime factor larger than 256.

Maybe easier and better is to set the first timer to run continuously, and as a slave in gated mode; then set the second timer to produce a master pulse of length equivalent to the required total number of pulses times the first timer's period.

JW

unternehmen
Associate II
November 2, 2019

The first suggestion works better.

The proposal with master and slave timer causes strange behavior. After the pulses, the timers develop their own life. The used timer output toggles in a very small frequency. He should not output anything after the pulse.

waclawek.jan
Super User
November 2, 2019

Both my suggestions were master-slave, so I don't know which one do you have in mind, and I also don't know what exactly did you do, in terms of the timers' registers content.

JW

unternehmen
Associate II
November 2, 2019

​That works better in my application.

"You can set one linker to on-pulse with repeat N times, and set it to be slave triggered from other timer, which too runs in one-time with repetition M and with period Nx the first timer period. The number of pulses will be restricted to those which has no prime factor larger than 256."

This will always generate a rectangle on slave timer with a very low frequency at the output if I do not produce a master pulse.

"Maybe easier and better is to set the first timer to run continuously, and as a slave in gated mode; then set the second timer to produce a master pulse of length equivalent to the required total number of pulses times the first timer's period."

In my opinion, I have configured the timers as you described. Why the timers show this behavior, I can not explain.

I have the feeling that the slave timer overflows and the output toggles. The frequency looked like the minimum possible frequency.

waclawek.jan
Super User
November 2, 2019

We probably misunderstand each other.

"Maybe easier and better is to set the first timer to run continuously, and as a slave in gated mode; then set the second timer to produce a master pulse of length equivalent to the required total number of pulses times the first timer's period."

Here, the slave is the timer which outputs the pulses to a pin. It is set to a period and duty required to output the pulses. The master produces one single long pulse, with the duration of the total of all required pulses, which is not output to a pin, but only gates the slave's clock.

Thus, should the master somehow fail to gate the slave, the slave would output a fast stream of pulses.

JW