2023-06-22 06:39 AM
Hi,
I'm generating a variable duty PWM on HRTIM1, Timer A, unit 1. It is configured to 500 kHz, with a 217 ps resolution.
I want to update the duty value every 50 kHz. It works, but on some steps, the duty glitches to high state (it seems that the compare value doesnt work on these cycles, since my compare value doesnt change on this tests).
The PWM configuration is:
I do the duty update with
// Write the value to compare in the register.
pCompareCfg.CompareValue = pwm_duty;
// Apply the compare configuration to the dessire timer unit in this case HRTIM-A1
HAL_GpioSet(HAL_GPIO_OUT_Led2, HAL_GPIO_HIGH);
HAL_HRTIM_WaveformCompareConfig(&hhrtim1, HRTIM_TIMERINDEX_TIMER_A, HRTIM_COMPAREUNIT_1, &pCompareCfg);
HAL_GpioSet(HAL_GPIO_OUT_Led2, HAL_GPIO_LOW);
In the figure, red trace is the GPIO and yellow is the PWM output.
I've also tried with:
__HAL_HRTIM_SETCOMPARE(&hhrtim1, HRTIM_TIMERINDEX_TIMER_A, HRTIM_COMPAREUNIT_1, pCompareCfg.CompareValue);
HAL_HRTIM_SoftwareUpdate(&hhrtim1, HRTIM_TIMERINDEX_TIMER_A);
Anyone has experienced this issue or know why happens?
Thanks!
2024-01-04 08:04 PM
Hello @MCris.4
I am also facing the same issue with HRTimer A running at 5 kHz and modulated with sinewave of 50 Hz.
when duty is near about 56%, HRTimer A is missing one pulse which is exactly the same as shown in your above post.
Let us know, if you find out some solution.
@SofLit could you please support us with some solution. Thanks in advance.
Regards,
Nikhil
2024-01-10 07:52 PM
I got this issue resolved for my case.
I changed the greater than comparison setting as below.
You may please check with this setting at your end.
Regards,
Nikhil