2020-01-11 02:31 AM
Hello,
I am Sai hope you are doing well
I am facing some issues with the timers .
I am using stm32f4,f7 micro controller to pulse step input of stepper motor driver. I have configured my timer using HAL layer. i want sweep the frequency from 100hz to say 200khz at the rate of few milliseconds(12ms) .
In my application peripherals are configured as tim3 as base timer and tim1 as output compare toggle mode(using it for step pulse) and at every timer 3 update event i am updating the period of timer1 in order to change the frequency(without knowing weather update event of tim1 occurred or not ). Everything is working as expected but most of the time my motor takes jerks i am assuming that multiple times updation of tim1 period creating some glitches in step pulse . I dont have any way to confirm.
If i generate step pulse using GPIO in output mode then motor is accelerating smoothly without any **** but same thing i want to do using timer.
Is it feasible to update the timer ARR value frequently.
I have refereed to Cross timer and general purpose time cookbook application notes but didnt got correct way to achieve this task efficiently.
thanks all
Solved! Go to Solution.
2020-01-11 06:12 AM
I think that you are missing the ARR preload feature, enable it by
TIM1->CR1|=TIM_CR1_ARPE;
this way, the ARR register update will be delayed to occur at the next counter overflow. See the timing diagrams with and without ARPE in the timer feature description/counter modes chapter in the reference manual.
2020-01-11 06:12 AM
I think that you are missing the ARR preload feature, enable it by
TIM1->CR1|=TIM_CR1_ARPE;
this way, the ARR register update will be delayed to occur at the next counter overflow. See the timing diagrams with and without ARPE in the timer feature description/counter modes chapter in the reference manual.
2020-01-11 03:51 PM
You can use the PWM_timer "overflow bit" to trigger the DMA to update the ARR from a circular buffer table.
2020-01-12 09:24 AM
You can use one timer as a master step pulse generator and another timer as a slave microstep counter with a "period" of full step. Then in slave driver's update interrupt modify the master driver's period after each full step.