cancel
Showing results for 
Search instead for 
Did you mean: 

HRTIM variable PWM glitch on STM32F334R8

MCris.4
Associate II

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: 

MCris4_0-1687441006734.png

MCris4_1-1687441041541.png

 

image6952.png

 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!

2 REPLIES 2
Nsg1987
Senior

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 

 

Nsg1987
Senior

@MCris.4 

I got this issue resolved for my case. 

I changed the greater than comparison setting as below.

 

Nsg1987_0-1704945067783.png

You may please check with this setting at your end.

Regards,

Nikhil