Ok sorted, this was a UI problem as @waclawek.jan suggested and adding  · HAL_TIM_PWM_Start · as @KSOdin2 made it work. Thanks for everyones help. Answer from cage on community.st.com
🌐
STMicroelectronics Community
community.st.com › t5 › stm32-mcus-products › how-to-toggle-gpio-using-the-quot-pwm-generation-no-output-quot › td-p › 74259
How to toggle GPIO using the "PWM Generation No Output" Timer mode ?
February 22, 2023 - I have a use case where I need to toggle a GPIO based on a PWM waveform. Since the GPIO chosen doesnt fall in the PWM timer pins, I have to toggle the GPIO in some other way. I came across the timer mode "PWM Generation No Output" mode. I am thinking of generating the desired PWM using this timer mo...
Discussions

timer - STM32 NUCLEO64: PWM has no output - Stack Overflow
I'm using STM32F303 NUCLEO64. I used CubeIDE to auto generate the code. The program is running Coz I can see the printf() is updating via SWO. I have added 1 sec delay after GPIO and TIM3 initaliza... More on stackoverflow.com
🌐 stackoverflow.com
stm32 - stm32f103c8t6 : Problem in PWM generation on timer output channel - Electrical Engineering Stack Exchange
My Objective is to Generate PWM with duty cycle = 50 % , Frequency = 50 Hz using General Purpose Timer 2 in output channel 2 which is at PA1 or pin number 11 My Target System is STM32 BluePill development board · Target Controller is STM32F103C8T6 MEDIUM DENSITY DEVICE ... I configured the GPIOA in Alternate function output Push Pull mode with maximum frequency not ... More on electronics.stackexchange.com
🌐 electronics.stackexchange.com
July 2, 2017
TIMER->PWM GENERATION NO OUTPUT->DMA->GPIO
EEVblog Captcha · We have seen a lot of robot like traffic coming from your IP range, please confirm you're not a robot · This security check has been powered by · CrowdSec More on eevblog.com
🌐 eevblog.com
STM32 bare metal non-halting PWM generation?
Haven't used this particular ship. What I can gather from the reference manual: set up a timer in PWM mode and change its TIMx_CCRx value in your interrupt or loop. More on reddit.com
🌐 r/embedded
10
22
April 13, 2022
🌐
STMicroelectronics Community
community.st.com › t5 › stm32-mcus-products › how-to-toggle-gpio-in-the-pwm-generation-no-output-mode › td-p › 575858
How to toggle GPIO in the PWM Generation No Output... - STMicroelectronics Community
July 20, 2023 - HAL_TIM_PWM_Start_IT(&htim17, TIM_CHANNEL_1); //--> Start PWM with IT · It should run fine. ... 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. ... If like Mehdi, you did generate your code through STM32CubeMx, your callback should be written automatically in stm32g0xx_it.c file.
🌐
Stack Overflow
stackoverflow.com › questions › 74051084 › stm32-nucleo64-pwm-has-no-output
timer - STM32 NUCLEO64: PWM has no output - Stack Overflow
According to the datasheet (DS9773) this equates to TIM1_CH2N, which is not what you want. I think you need to configure PB0 as GPIO_AF1_TIM3, which is TIM3_CH3. I don't have this Nucleo board, but I created a project for it in CubeIDE and configured TIM3 for PWM output on channel 3, and it auto-generated code that configured PB0 as GPIO_AF1_TIM3.
🌐
DeepBlue
deepbluembedded.com › home › blog › stm32 pwm output example code (pwm generation tutorial)
STM32 PWM Output Example Code (PWM Generation Tutorial)
February 7, 2025 - There is no way to go around this fact. As we've discussed in an earlier tutorial, the STM32 timer modules can operate a variety of modes one of which is the PWM mode. Where the timer gets clocked from an internal source and counts up to the auto-reload register value, then the output channel pin is driven HIGH.
🌐
EEVblog
eevblog.com › forum › microcontrollers › timer-gtpwm-generation-no-output-gtdma-gtgpio
TIMER->PWM GENERATION NO OUTPUT->DMA->GPIO
EEVblog Captcha · We have seen a lot of robot like traffic coming from your IP range, please confirm you're not a robot · This security check has been powered by · CrowdSec
Find elsewhere
🌐
Reddit
reddit.com › r/embedded › stm32 bare metal non-halting pwm generation?
r/embedded on Reddit: STM32 bare metal non-halting PWM generation?
April 13, 2022 -

I have an STM32F407 board.

I have a main function which measures tilt values using a gyroscope. This value is processed in a PID controller, which results in a float output value.

I would like to use this output to change the frequency of a square wave on one of my output pins without halting the main process. So the signal is continuously generated in the background, the main loop just sets it's speed in every cycle.

I am not using CubeMX and HAL, so I would like to implement this using registers too.

Can someone point me in the right direction?

🌐
Stack Overflow
stackoverflow.com › questions › 65590323 › no-pwm-output-on-stm32
stm32f4discovery - No PWM Output On STM32 - Stack Overflow
You should set Pulse value greater than zero and less than your period value; it is duty of your PWM. Zero duty generates zero out.
🌐
Medium
medium.com › @pqshedy33 › how-to-use-pwm-on-stm32-8852be201a79
How to use PWM on STM32?. Using PWM (Pulse Width Modulation) on… | by Ampheo | Medium
June 17, 2025 - Using PWM (Pulse Width Modulation) on an STM32 microcontroller involves configuring one of its TIM (Timer) peripherals in PWM output mode. Here’s a complete guide using STM32CubeMX and HAL library, plus a brief explanation for register-level access if needed. ... Select your target MCU or board (e.g., STM32F103C8T6). ... Choose a Timer Channel pin (e.g., PA8 → TIM1_CH1). Click it and set to “PWM Generation CHx”.
🌐
STMicroelectronics Community
community.st.com › stmicroelectronics community › discussions › product forums › stm32 mcus › stm32 mcus products › pwm no output
PWM No Output | Community
July 26, 2023 - For Channel 1 yours reads "PWM Generation CH1", mine reads "PWM Generation No Output". Question is what is the difference and why. ... And how do you define the pin on PA6? If it is a GPIO, it can no longer be used for PWM output. Must be configured as a TIM......... ... It works for me. Using the latest STM32CubeMX 6.9.0 and STM32L052K6T6 MCU.
🌐
Arm Community
community.arm.com › developer › tools-software › tools › f › keil-forum › 43982 › pwm-generation-problem-in-stm32f446zet
PWM generation problem in STM32F446ZET - Keil forum - Support forums - Arm Community
August 29, 2019 - Hello friends I am trying to generate PWM using TIM4 in STM32F446ZE, But There is no proper output from the controller Here i am sharing my code with you, please
🌐
STMicroelectronics Community
community.st.com › t5 › stm32-mcus-products › pwm-output-not-generating-waveform-for-stm32f429zi › td-p › 62398
Solved: PWM Output Not Generating Waveform for STM32F429ZI - STMicroelectronics Community
January 11, 2022 - Hi everyone, I'm just trying to test and verify some clock frequencies for a PWM waveform are correct. I used CubeMX to generate some code that has set the clock frequency of the MCU to 72 mHz and I am trying to achieve a 20 kHz PWM frequency. I enabled Timer 1 with channel 1 as the output channel (...
🌐
ControllersTech®
controllerstech.com › home › stm32 tutorials › stm32 timers series › generate pwm output
STM32 PWM Tutorial: Generate PWM with DMA using HAL
This tutorial provides detailed steps, code examples, and waveform explanations that show how DMA can be used to generate efficient and continuous PWM signals on STM32 microcontrollers. ... This video walks through the complete STM32 PWM setup using TIM1 in CubeMX and HAL. It covers clock and timer configuration, calculating PSC and ARR for a target frequency, starting PWM output, changing the duty cycle at runtime, and using DMA in both Normal and Circular modes — with live logic analyzer output.
Published   April 30, 2026
🌐
Edaboard
edaboard.com › digital design and embedded programming › microcontrollers
[STM32] Strange behaviour on PWM output, duty-cycle <50% | Forum for Electronics
June 13, 2023 - Hi, if there is a problem generating less than 50% duty cycle ouput then it´s a problem of the STM32 code. The external hardware has nothing to do with it. (indeed we even don´t know the PWM1 voltage levels. So a review of the signal is impossible.) --> Just check "PWM1" node timing.
🌐
STMicroelectronics Community
community.st.com › s › question › 0D50X00009XkXb6SAF › problem-in-pwm-generation-on-timer-output-channel
Solved: Problem in PWM generation on timer output channe... - STMicroelectronics Community
March 24, 2019 - Also when you put the pulse to zero the pin goes to a high state and don't know if you have the LED configured active low or high. ... Because you are using PWM2 which means the pulse is negative instead of Positive with PWM1, if you set the counter to zero the pin stays in the high state which ...
Top answer
1 of 1
1

You don't need the complexity of chained timers to achieve this on STM32. You can either use TIM_RCR for certain timers to have a Nth UEV interrupt change polarity, or you can simply implement a software counter in an UEV interrupt handler to emulate RCR.

But the most important thing is to use preloaded OC register control for correct glitch-free operation. There are two modes of preloaded control that you can use (TIM1 as an example):

  1. Output in PWM mode with preloaded OC control:
TIM1_CCMR1 = TIM_CCMR1_OC1PE | TIM_CCMR1_OC1M_PWM1;

In this mode, TIM_CCR1 is preloaded, i.e. any changes to it will be applied after UEV (update event). In other words, every write operation changes the next duty cycle, not the current.

This mode is mandatory for glitch-free PWM mode operation.

  1. Preloaded commutation control:
TIM1_CR2 = TIM_CR2_CCPC;

In this mode, changes to certain bits in the TIM1_CCMRx and TIM1_CCER registers are preloaded. The values programmed are applied upon COM (commutation event) which can arrive either as a trigger or via TIM1_EGR = TIM1_EGR_COMG.

This mode is required for glitch-free commutation control.


In your code, you change polarity via TIM2_CCER without any preloaded control enabled, hence glitches are unavoidable. It's also worth noting that your code has excessive latency due to weird statements like while(TIM2->CNT);. In correctly written code, changing polarity even without preloaded control will still give good results albeit not ideal.

The initial requirement is: The original firmware generates PWM (duty cycle 50%) and every 8 cycles inverts the signal

It's hard to come with a good solution without further details. It's unknown, for example, whether duty cycle is always fixed at 50% or should change. If it's fixed, we can come up for instance with another approach - use timer PWM mode with preloaded OC control at twice the frequency and have duty cycle alternate between 0% and 100% in a preloaded fashion. At the 8th iteration, alternation changes.

A very simplified interrupt-based example:

void tim1_up_isr(void) {
    static int n;
    if (!(++n & 7)) return; // Change polarity every 8th iteration, i.e. do not alternate
    TIM1_CCR1 ~= TIM1_CCR1; // Alternate duty cycle between 0% and 100%
}

...
TIM1_BDTR = TIM_BDTR_MOE; // Enable main output
TIM1_CCMR1 = TIM_CCMR1_OC1PE | TIM_CCMR1_OC1M_PWM1; // PWM1 mode, buffered CCR1
TIM1_CCER = TIM_CCER_CC1E; // Enable output
TIM1_DIER = TIM_DIER_UIE; // Enable UEV interrupt

The above is just an example of the preloaded PWM control concept and in no way is the most efficient code.

In the ultimate case, when duty cycle can change and on-the-fly polarity/mode change is required, the only correct way is to use both preloaded commutation control and PWM mode with preloaded OC control.