0

Using a Raspberry Pi 3B+ with

Linux raspberrypi 5.10.103-v7+ #1529 SMP Tue Mar 8 12:21:37 GMT 2022 armv7l GNU/Linux

I would like to drive an LED with pwm.

There are two couples of GPIO pins which also support pwm: according to this page, they are the physical pins 12, 32 and 33, 35.

I can list them as

# cat /sys/kernel/debug/pwm
platform/3f20c000.pwm, 2 PWM devices
 pwm-0   ((null)              ): period: 0 ns duty: 0 ns polarity: normal
 pwm-1   ((null)              ): period: 0 ns duty: 0 ns polarity: normal
  1. How can I determine to which couple of pins do pwm-0 and pwm-1 correspond?
  2. To drive an LED (in series with a resistor) with pwm, should I use both the pins of a pwm couple, for example pins 12, 32, or is it enough to use just one of them and a simple ground pin?
BowPark
  • 101
  • 2

1 Answers1

1

PWM0 is GPIO 12 or 18 (as the link you posted shows).

The same signal can be on either or both.

You only need 1 channel to control a LED.

It is unclear how you plan to use PWM (there are only a few libraries for hardware PWM). The sysfs implementation (which you appear to be using) is rather poorly documented although I have written code to use it. See https://raspberrypi.stackexchange.com/a/143644/8697

Frankly you don't need hardware PWM to control a LED and there more libraries which support software PWM which allow any pin.

Milliways
  • 62,573
  • 32
  • 113
  • 225