Skip to main content
Explorer II
November 28, 2023
Solved

STM32F030R8 PWM to LED (PA5)

  • November 28, 2023
  • 2 replies
  • 1570 views

Hi all, 

I am looking into generating a PWM signal using the Timers and route it to the PA5 pin to blink the LED, but PA5 does not have a TIM routed to it. I thought about just having a timer work in my code and toggle the pin every second by checking the counter register, but is there any better / cleaner way to use PWM with the LED pin on this model?

Thank you!

tolgaust_0-1701193381887.png

 

    This topic has been closed for replies.
    Best answer by Peter BENSCH

    Welcome @tolgaust, to the community!

    I you don't want to connect an external LED to a GPIO with a timer, you can switch PA5 to analogue or digital input (should be the uninitialised default value) and connect the timer of another GPIO to it by wire. As PA5 is then high-impedance, the timer can apply any level to it (which must of course be within the permissible range).

    Good luck!
    /Peter

    2 replies

    Technical Moderator
    November 28, 2023

    Welcome @tolgaust, to the community!

    I you don't want to connect an external LED to a GPIO with a timer, you can switch PA5 to analogue or digital input (should be the uninitialised default value) and connect the timer of another GPIO to it by wire. As PA5 is then high-impedance, the timer can apply any level to it (which must of course be within the permissible range).

    Good luck!
    /Peter

    Super User
    November 28, 2023

    For low speeds, up to 1 kHz or so, using an interrupt is straightforward and will work well.

    For extreme speeds, say tens or hundreds of kHz, you could use DMA. But the code complexity required doesn't warrant using it for low speeds.