Unable to set HRTIM PWM duty cycle
I am trying to use the HRTIM peripheral on the STM32Hh753VI as a PWM generator with variable duty cycle. I want to use Timer B1 on pin PC8.
Firstly, I tried using Simple HAL functions:
HAL_HRTIM_SimplePWMStart(&hhrtim, HRTIM_TIMERINDEX_TIMER_B, HRTIM_OUTPUT_TB1);Indeed a PWM signal is seen on pin PC8. However, I am unable to change the duty cycle. The macro __HAL_HRTIM_SETCOMPARE has no effect.
__HAL_HRTIM_SETCOMPARE(&hhrtim, HRTIM_TIMERINDEX_TIMER_B, HRTIM_COMPAREUNIT_1, x);The signal on the output does not change, regardless of the value I give. Looking at the compare register via the SRF view, I see that the compare value does change, but it does not have any effect on the output.
Secondly, I tried to use the Advanced/Waveform methods. However, in this case I get no output at all. I am following the BuckBoost example project for the STM32F3348 from STM32CubeF3. This is how I am attempting to start the output. However, the voltage stays at 0.
HAL_StatusTypeDef res1, res2, res3;
HRTIM_CompareCfgTypeDef compare_config;
compare_config.AutoDelayedMode = HRTIM_AUTODELAYEDMODE_REGULAR;
compare_config.AutoDelayedTimeout = 0;
compare_config.CompareValue = 0x1FFD;
res1 = HAL_HRTIM_WaveformCompareConfig(&hhrtim, HRTIM_TIMERINDEX_TIMER_B, HRTIM_COMPAREUNIT_1, &compare_config);
res2 = HAL_HRTIM_WaveformOutputStart(&hhrtim, HRTIM_OUTPUT_TB1);
res3 = HAL_HRTIM_WaveformCounterStart(&hhrtim, HRTIM_TIMERID_TIMER_B);How can I:
- Change the duty cycle in Simple mode
OR
- Enable the output in Advanced mode?
Kind regards,
Jim
