cancel
Showing results for 
Search instead for 
Did you mean: 

one Timer PWM, 2 LEDs

Ala
Senior

Hey there

I want to use one and only one Timer to generate PWM signal to control 2 LED lights. assume that PWM generated is only attached to one the LEDs. how can I make both of LEDs shine or dim with only one PWM?

thanks in advance for any help and hint in advance

8 REPLIES 8
MM..1
Chief II

Your question lacks info what is your idea. One Timer in normal have more channels for example 4

You can create different duty PWMs on every channel.

Or when you ask how 2 LEDs use electrical serial or parallel or one transistor driver or two or ....

you are right MM.1! so here is my situation: one of the LEDs is connected to TIM so I can generate and control PWM.

but the other has no TIM channel connected to it! none what so ever...

my goal is to simultaneously dim or light these LEDs. say I use TIM14 CH1 which is connected to LED1. easily I can dim or shine LED1 using TIM14 CH1.

but LED2 has no TIM connected to it. but I still want to control its light with the same PWM I generated for LED1.

how can I do that?

Nikita91
Lead II

Don't configure the GPIO of LED2 and add a wire to your board.

Javier1
Principal

I already commented in your other similar question, you could do softpwm for both pins (extra fast points if both pins belong to the same GPIO port)

So no timer , and infinite number of PWms

https://www.hackster.io/javier-munoz-saez/all-pins-as-pwm-at-the-same-time-baremetal-stm32-1df86f

we dont need to firmware by ourselves, lets talk

seems easy! but the thing is I just can not change the hardware...

I wondered if I can generate an internal PWM signal and logically OR it with this LED... but I don't know how?

Thanks Javier!@Javier Muñoz​ 

I was just reading your comments. but I didn't understand it completely...I'll try to figure it out somehow though... how can I ask you if I face any conflict?

You can post your questions in this forum and tag my name so i dont miss it @Javier Muñoz​ 

we dont need to firmware by ourselves, lets talk
MM..1
Chief II

Simply Leave LED1 as is and in ISR timer interrupt add GPIO LED2 high and low.