cancel
Showing results for 
Search instead for 
Did you mean: 

Configure stm32g474 HRTIM ?

xcm
Associate II

tima 的pwm输出正确,但是timb的pwm一个周期出现无法reset的情况

1000063108.jpg

10 REPLIES 10
Imen.D
ST Employee

Hello @xcm 

Please try to write in English to make sure you can get an answer, because most of the people on this community can speak English but not Chinois.
If possible, to provide more details on your issue and share your code, TIM configuration, software version used.

Did you check the known HRTIM limitations in the STM32G471xx/473xx/474xx/483xx/484xx device errata - Errata sheet?

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
xcm
Associate II

ok,

void HAL_HRTIM_RepetitionEventCallback(HRTIM_HandleTypeDef *hhrtim, uint32_t TimerIdx)//20kHz中断
{
if (TimerIdx == HRTIM_TIMERINDEX_TIMER_A)
{
HAL_HRTIM_WaveformOutputStart(&hhrtim1,HRTIM_OUTPUT_TA1 | HRTIM_OUTPUT_TA2 | HRTIM_OUTPUT_TB1 | HRTIM_OUTPUT_TB2 | HRTIM_OUTPUT_TC1 | HRTIM_OUTPUT_TC2);
//HAL_HRTIM_WaveformOutputStart(&hhrtim1,HRTIM_OUTPUT_TB1 | HRTIM_OUTPUT_TB2);

hhrtim1.Instance->sTimerxRegs[0].CMP1xR = SPWM_400[i];
hhrtim1.Instance->sTimerxRegs[0].CMP3xR =SPWM_400[399-i];

hhrtim1.Instance->sTimerxRegs[1].CMP1xR = SPWM_400[i];
hhrtim1.Instance->sTimerxRegs[1].CMP3xR = SPWM_400[399-i];

}
}

The two PWM is not the same as the picture shows.how to solve it.every period has a wrong pwm(50Hz).


Edited to apply source code formatting - please see How to insert source code for future reference.

xcm
Associate II

ok,

void HAL_HRTIM_RepetitionEventCallback(HRTIM_HandleTypeDef *hhrtim, uint32_t TimerIdx)//20kHz中断
{
if (TimerIdx == HRTIM_TIMERINDEX_TIMER_A)
{
HAL_HRTIM_WaveformOutputStart(&hhrtim1,HRTIM_OUTPUT_TA1 | HRTIM_OUTPUT_TA2 | HRTIM_OUTPUT_TB1 | HRTIM_OUTPUT_TB2 | HRTIM_OUTPUT_TC1 | HRTIM_OUTPUT_TC2);
//HAL_HRTIM_WaveformOutputStart(&hhrtim1,HRTIM_OUTPUT_TB1 | HRTIM_OUTPUT_TB2);

hhrtim1.Instance->sTimerxRegs[0].CMP1xR = SPWM_400[i];
hhrtim1.Instance->sTimerxRegs[0].CMP3xR =SPWM_400[399-i];

hhrtim1.Instance->sTimerxRegs[1].CMP1xR = SPWM_400[i];
hhrtim1.Instance->sTimerxRegs[1].CMP3xR = SPWM_400[399-i];

}
}

The two PWM is not the same as the picture shows.how to solve it.every period has a wrong pwm(50Hz).TA1(the red one) is correct while the TB1(the yellow one) is not the same as i set.


Edited to apply source code formatting - please see How to insert source code for future reference.

Imen.D
ST Employee

What about CKPSC? Make sure to adjust the clock prescaler and timing parameters to ensure cycle accuracy.

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
xcm
Associate II

xcm_0-1751533256936.png

xcm_1-1751533268109.png

which one?what can I do ?

xcm
Associate II

How to set CKPSC,which one is better?

xcm
Associate II

hello,what can i do?

 

Hello @xcm 

Please share more details about your issue.

You can refer to the examples below:

STM32CubeG4/Projects/STM32G474E-EVAL/Examples/TIM at master · STMicroelectronics/STM32CubeG4 · GitHub

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Saket_Om

what issue do you want to see?