Trying to find best and most reliable way when using the STM32 timers to change the timebase 'on the fly'.
Hi, I've recently retired from being an electronics design engineer for over 40 years. I wanted to have some fun playing around with micros to do some basic control. I have both the Nucleo-F030R8 and STM32F4 Discovery evaluation boards and have been teaching myself on STM32CubeIDE. I am at the stage of writing some basic code and running it on the F0 board, The ST videos have been very helpful. What I'm trying to do is to create a timebase to drive a unipolar stepper motor driver board clock (I have lots of hardware already). I am currently using one of the timers in PWM mode to do this with pulse set to zero (my clock to the driver board is edge triggered and the driver board takes care of the motor phase outputs). The reason for this request is I'm trying to create a simple acceleration profile. So far I have a clock output which I've been able to change period on a cycle by cycle basis within the main code using the period end interrupt to set a flag which is detected and the ARR register changed, which seemed to work well. I've now progressed to try to get this to work within the ISR (period end triggered) without much success. Can one actually change the Timer ARR register so that it sync's every cycle to get a different consecutive period lengths. I'm thinking if the ARR register is changed in the ISR will that 'miss' the next cycle. I've not found a way yet of finding an interrupt that is say a proportion into the period where I can change the ARR value to guarantee a change at the next cycle. I could use the pulse width within the timer when set to PWM mode but that means I will also have to change that every time as well. Also, I've not managed to find a way of setting a Timer in base interrupt mode to drive an output pin, which may be easier than using in PWM mode. All this done by a lot of experimentation, maybe I'm just getting too old for this :) If anyone can give me some pointers I would be most grateful. In the meantime I'll keep trying and learning. Thanks
