AnsweredAssumed Answered

Generating PWM Waveform with STM32L011?

Question asked by Yasmin Bragg on May 10, 2018
Latest reply on May 10, 2018 by waclawek.jan

Hi all,


I'm new to using timers and I'm currently trying to generate a PWM Waveform so that I can use this to power some motors. At the moment I am testing the PWM Waveform via LED's rather than going straight to the motors. I'm using the STM32L011K4T6 development board to try and do this.


By looking at AN4013 (STM32 Cross-Series Timer Overview) Section 2.5 "Timer PWM Mode" I have come up with what I thought should get the PWM waveform generated, I've attached files with the code in as well as the document I was using. From this I thought I would be able to see a noticeable difference between two LED's by setting the CCRx values to different amounts. 


I'm trying to output the waveform to PA8 (AF5 = TIM2_CH1) and PA10 (AF5 = TIM2_CH3). When I run the code the LED's light up ever so slightly, however, modifying the CCRx value does nothing to change this brightness, and even when I set it to 0 the LED's are still lit up slightly. Obviously, I've gone wrong somewhere but I just can't see what I need to modify to get this to work.  Do I need to do anything within the main body of code on top of the initialization to get it to work or is it something within the initialization routine I've got wrong?


I'd really appreciate any help with this.