2015-05-23 08:59 AM
Hi!
I am working now on the project (STM32F429i board) where I need to profile the velocity of servo motor (i.e. trapezoidal velocity)... So I need to control the number of pulses I've sent via PWM channel, to control position of servo motor... Would You suggest me a few method which I can use to do that...? And which is the best...?Now I am using 2 timers linked by wire: one in PWM Out Mode and the other in Input Capture Mode with External CLK on this pin.This method has ''quite good results'' I dont know if it is the best or only method to implement...Thanks for any advice,Marcin #timer-modes #stm32f4292015-05-23 06:27 PM
Well the advanced timers (TIM1 and TIM8) have an 8-bit repetition count.
Other than that I'd probably either use another TIM in external count mode, or simply count Update interrupts from something that's low bandwidth like 50 Hz2015-05-24 01:36 AM
Hi!
Yes I thought about configuring counting timer in external clock mode 1. But the interrupt (to turn of PWM timer) is generated only when counter is overflowed (update interrupt)...In my project I need to send different size and frequency packages of pulses and turn off PWM timer when enough pulses were sent. So to do that in external clk mode 1, I would have to reconfigure counting timer ARR register periodically, before/while generation of each package... Is it a good programistic idea? And if is it possible to work properly...? (I work with frequencies from 1Hz to 200kHz)2015-05-24 03:04 PM
It can interrupt on things other than Update (Rollover), you can use the CCRx register to interrupt when it hits specific set points, and you can advance those setting to counts in the future. ie TIM2->CCR2 += 1000;
For complex patterns to a single register within the timer there is also DMA, you can have the DMA interrupt half way through or at the end of a pattern.2015-05-25 03:36 AM
So when the value of counter reach to the CCRx register value the TIMx_IRQHandler() is called...? Or some other interrupt function...?
2015-05-25 07:28 AM
So when the value of counter reach to the CCRx register value the TIMx_IRQHandler() is called...? Or some other interrupt function...?
Yes for most timers there's just one interrupt handler and all interrupts go there, and you qualify the source in your handling code. Review the startup_stm32fxx.s file to see all the interrupt vectors, and confirm those available for a specific TIMx