Skip to main content
Nsg1987
Associate III
May 12, 2023
Solved

How to force stop PWM pins in complementary.

  • May 12, 2023
  • 3 replies
  • 2427 views

Hello,

I am working on STM32G474.

I want to operate PWM using GPIO. Below code works find for me. but the issue is that after triggering PWM to stop (only output will be stopped and counter remains working), the PWM of timer 1 takes almost 1.2 seconds to logic 0 level. Is there any other way to force both PWM pins (complemtary) to low level as soon as trigger from GPIO arrived. I want to remove delay of 1.2 seconds which takes to force PWM pins to low.

This topic has been closed for replies.
Best answer by waclawek.jan

> The PWM of timer 1 takes almost 1.2 seconds to logic 0 level.

Would you use an oscilloscope instead of LA, you would see a slowly decaying signal - you've threestated the given pin by clearing the respective TIMx_CCER.CCxE/CCxNE bit, but the parasitic capacitances (I guess in your case mainly of a connected relatively big MOSFET) "holds" the charge for some time.

The simplest thing to do is to switch on pulldown on the pin.

If you want to pull the pin down actively, the simplest thing to do is to change the given pin's GPIO_MODER setting from AF to Out (and of course have respective GPIO_ODR set at 0).

A more sophisticated option is to utilize MOE and OSSI (and OISx/OISxN) in the Advanced timers:


_legacyfs_online_stmicro_images_0693W00000bjzFeQAI.pngJW

3 replies

AScha.3
Super User
May 12, 2023

i would use the break feature of tim1 .

set break output state/levels as you like and then , when set brake by software, all outputs go to this state immediately .


_legacyfs_online_stmicro_images_0693W00000bjyg1QAA.png

"If you feel a post has answered your question, please click ""Accept as Solution""."
waclawek.jan
waclawek.janBest answer
Super User
May 12, 2023

> The PWM of timer 1 takes almost 1.2 seconds to logic 0 level.

Would you use an oscilloscope instead of LA, you would see a slowly decaying signal - you've threestated the given pin by clearing the respective TIMx_CCER.CCxE/CCxNE bit, but the parasitic capacitances (I guess in your case mainly of a connected relatively big MOSFET) "holds" the charge for some time.

The simplest thing to do is to switch on pulldown on the pin.

If you want to pull the pin down actively, the simplest thing to do is to change the given pin's GPIO_MODER setting from AF to Out (and of course have respective GPIO_ODR set at 0).

A more sophisticated option is to utilize MOE and OSSI (and OISx/OISxN) in the Advanced timers:


_legacyfs_online_stmicro_images_0693W00000bjzFeQAI.pngJW

Nsg1987
Nsg1987Author
Associate III
May 15, 2023

Its working now. As suggested above, I pulled down the pins and it is working as expected.