PWM on PB5 pin

Post here first, or if you can't find a relevant section!
Post Reply
geologic
Posts: 23
Joined: Thu Dec 15, 2022 10:12 am
Answers: 2

PWM on PB5 pin

Post by geologic »

Hi all

I have a PWM RGB led connected to PB5 (red), PB14 (green) and PB2 (blue) on a custom board with STM32L051T6.
Can someone confirm that PB5 is a PWM pin ?
From https://www.st.com/resource/en/datashee ... l051c6.pdfpage 42 it says TIM22_CH2, but when i do a analogWrite(PB5,255) does not output red. When doing analogWrite() on PB14 or PB2 it outputs the corresponding color.

Thanks
fpiSTM
Posts: 1946
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 108
Location: Le Mans
Contact:

Re: PWM on PB5 pin

Post by fpiSTM »

PB5 has a timer:
https://github.com/stm32duino/Arduino_C ... Pins.c#L89
But PB14 and PB2 do not have one.
So doing analogWrite(PB2, 255) is the same than doing digitalWrite(PB2, HIGH).
Try digitalWrite(PB5, HIGH).
geologic
Posts: 23
Joined: Thu Dec 15, 2022 10:12 am
Answers: 2

Re: PWM on PB5 pin

Post by geologic »

digitalWrite(PB5, HIGH) works (red color), but analogWrite(PB5,xxx) does not work (shows a very dim red light)
analogWrite(PB14,128) and analogWrite(PB2,128) also works (mid tone green and blue)

So, how to tell witch pins are PWM?
GonzoG
Posts: 498
Joined: Wed Jan 15, 2020 11:30 am
Answers: 36
Location: Prudnik, Poland

Re: PWM on PB5 pin

Post by GonzoG »

@geologic,
there's no support for L051T MCU. Unless you've added it yourself (and may not be done correctly), you had to use different MCU and it may not (probably won't) work.
Post Reply

Return to “General discussion”