2022-01-05 07:33 AM
I am using a STM32G431RB MCU and the STM32Cube_FW_G4_V1.5.0 package for motion control. In addition to the usual SysTick 1ms time base a second, faster time base is needed to run control loops. I plan to use a general-purpose timer (e.g. TIM2) to implement the fast time base.
Question: the SysTick uses the HAL functions (HAL_IncTick etc.). Is it advised to implement custom functions for the fast time base, or are additional libraries available, HAL or others? Thank you.
2022-01-05 08:00 AM
If you need a second timer, start one in free-running mode and read it when necessary. Generally this would be done independently from SysTick.
You can also use the free-running 32-bit DWT timer for maximum resolution.
2022-01-05 08:17 AM
Hello TDK, thank you for your helpful and quick response. Please comment on this idea, which I think is not unusual: the callback function for the free-running timer executes the velocity control, updates the finite state machine, etc. The timer frequency (period) provides a precise loop update rate, let's say 2000 Hz. The main() loop is not needed for this. Thank you!
2022-01-05 08:25 AM