Skip to main content
Associate
November 28, 2023
Solved

STM32F030R8 PWM to LED (PA5)

  • November 28, 2023
  • 2 replies
  • 2256 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

Peter BENSCH
Peter BENSCHBest answer
ST 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

In order 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.
TDK
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.

"If you feel a post has answered your question, please click ""Accept as Solution""."