STM32G4 HRTIM Deadtime Prescaler incorrect setting after driver update
After updating the STM32CubeG4 Firmware Package from version 1.6.1 to 1.6.2, I discovered a bug that causes incorrect deadtime prescaler settings for HRTIM when using the LL driver and CubeMX. As a result, the deadtime value can change to a fraction of the original value without anyone noticing, which can lead to hardware damage.
If I set in STM32CubeMX 6.17.0:
HRTIM -> Timer x -> Dead Time -> Prescaler = "fDTG = fHRTIM * 2"
The generated code contains:
LL_HRTIM_DT_SetPrescaler(HRTIM1, LL_HRTIM_TIMER_x, LL_HRTIM_DT_PRESCALER_MUL2);
LL_HRTIM_DT_PRESCALER_MUL2 is defined as HRTIM_DTR_DTPRSC_2 -> Register HRTIM_DTxR DTPRSC[2:0] = 0x4
This results in the deadtime value:
t_DTG = 2^4 * (t_HRTIM / 8) = 2 * t_HRTIM = fHRTIM / 2
So instead of "fHRTIM * 2" I get "fHRTIM / 2"!
I think the confusion comes from the fact that in CubeMX the prescaler is set as a multiple of the frequency, but in the datasheet and driver the multiple of the period is described.
Before the driver update, there was an error in both CubeMX and the driver, which led to the correct settings.
In the mentioned update, the definitions of LL_HRTIM_DT_PRESCALER_ were modified/fixed.
Probably as a result of this report: STM32G4 HRTIM deadtime prescaler defines swapped
The Release Notes for STM32CubeG4 Firmware Package only mention "HAL HRTIM update, Fix HRTIM_Deadtime_Prescaler_Ratio macro definitions."

