2026-04-29 7:02 AM - last edited on 2026-04-30 2:51 AM by mƎALLEm
Hello, i am using F446 and i am contemplating using FreeRTOS CMSIS V2 software timer to generate PWM to control motors via motor drivers (IC chipset). Is this possible? Or must I use the hardware timer, TIM1~7 ?
2026-04-29 7:14 AM
@HMSEdinburge wrote:must I use the hardware timer, TIM1~7 ?
Why would you not want to use them? This is exactly what they're for !
2026-04-29 7:17 AM
Ok, but can this FreeRTOS software timer produce PWM like the hardware timer? Can they driver a motor?
Please share source code of software timer generating PWM, thx.
2026-04-29 7:19 AM
Hardware timers all use up, therefore I got use a software timer.
2026-04-29 7:24 AM
Then check if the hardware timers are really needed for the stuff they are doing now.
If your PWM is really slow (like <= 1 kHz carrier or so), then maybe software can handle this well enough.
Otherwise - not at least a 10 kHz interrupt available or so?
But all this doesn't really make sense in a device that has hardware / timers built for that purpose.
2026-04-29 7:30 AM
Of course it can be done - just like bit-banging any other interface.
But you will never reach anywhere near the performance of a dedicated hardware timer.
Your code will need to manually make every single output transition and timer adjustment - and fit this around whatever else your code is doing.
But it's just software; you can easily try it out - but pay particular attention to the CPU usage ...
2026-04-29 7:34 AM
all my hardware timer TIM1~7 all used, therefore only left software timer, but can software timer able to drive an external motor?
2026-04-29 7:41 AM - edited 2026-04-29 7:41 AM
@HMSEdinburge wrote:Hardware timers all use up
Really?
It looks like the F446 range has 14 timers:
https://www.st.com/en/microcontrollers-microprocessors/stm32f446/products.html
And there are STM32s available with up to 22 timers:
https://www.st.com/content/st_com/en/stm32-mcu-developer-zone/mcu-portfolio.html
2026-04-29 7:45 AM - edited 2026-04-29 7:47 AM
@HMSEdinburge wrote:can software timer able to drive an external motor?
A timer - whether software or hardware - just toggles an output pin.
It makes no difference to the timer (whether SW or HW) what is externally connected to that pin.
As @LCE said, the limitation on using SW timers is going to be the maximum speed achievable.
Also the CPU load.
But, again, you can easily just try it out: write some code to toggle a pin, watch it on your scope, check CPU utilisation...
2026-04-30 1:41 AM
Hello @HMSEdinburge
Well, it's doable but as @Andrew Neil and @LCE but do not expect high precision. Software timers can be used for motor control in low-precision or low-frequency applications. However, they are not a substitute for hardware timers when precise timing is required.
If the software timer you want to create have the same frequency and period as one of the hardware timers, you can create a variable that captures the hardware timer CNT register. Compare this variable with specified value (like a custom ARR) as a condition to perform the required task when the CNT register reaches the desired value for the software timer. This approach may improve precision slightly.
BR
Gyessine
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.