Skip to main content
YChen.9
Associate II
June 22, 2024
Solved

STM32G031 PWM output raising and falling time problem

  • June 22, 2024
  • 1 reply
  • 816 views

Hi,

I am using the PWM1 mode of the STM32G031 TIM1 and I noticed that the rising and falling edge time of its PWM output is about 20 ns. I have used the PWM fast mode but this time is not getting shorter. I would like to know if this time is normal? Because if I use the GPIO output mode to flip the output directly, this time can be as fast as 10ns

Thanks.

 

This topic has been closed for replies.
Best answer by MasterT

Try:

/**TIM2 GPIO Configuration
*/
GPIO_InitStruct.Pin = GPIO_PIN_5;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;  <<<<---------
GPIO_InitStruct.Alternate = GPIO_AF2_TIM2;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

1 reply

MasterT
MasterTBest answer
Lead II
June 22, 2024

Try:

/**TIM2 GPIO Configuration
*/
GPIO_InitStruct.Pin = GPIO_PIN_5;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;  <<<<---------
GPIO_InitStruct.Alternate = GPIO_AF2_TIM2;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);