2024-07-31 10:32 PM
2024-07-31 10:50 PM
The software handling is too slow to stop the hardware in time. You could improve a little by moving from HAL to low-level / register-level programming.
The fastest method will be using some form of timer synchronisation. Maybe application note AN4776 "General-purpose timer cookbook for STM32 microcontroller" brings you some ideas.
hth
KnarfB
2024-07-31 11:50 PM
> You could improve a little by moving from HAL to low-level / register-level programming.
Avoiding the Cube/HAL interrupt handling in fact will improve things a lot, and together with proper compiler optimization and adequately high interrupt priority will have no problem with a 10us latency (i.e. will be good up to 100kHz) on a 'F4xx running at its maximum system frequency.
But it's always better to solve this kind of problems using purely hardware, if possible.
> The fastest method will be using some form of timer synchronisation.
That probably means the master-slave (TRGO-TRGI) interconnection between timers; however, there is no slave-mode controller in TIM10 in 'F4, so you'd need to choose a different timer. Starting/stopping a timer from another timer through writing to its registers using DMA may be an effective option, but it's not the simplest one.
You can also work around the problem e.g. by using SPI+DMA and outputting multiple-of-8 or -16 pulses on SCK.
JW