cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F030R8 PWM to LED (PA5)

tolgaust
Associate II

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
Peter BENSCH
ST Employee

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.

View solution in original post

2 REPLIES 2
Peter BENSCH
ST Employee

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
Guru

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".