1

Some internet resources mentioned that RP1 chip on RPi 5 has 4-channel PWM output. For example, this one. I was able to make 2 outputs working by adding dtoverlay=pwm-2chan to /boot/firmware/config.txt and using the script below. However, I can not figure out if and how the one can get 4 hardware PWM outputs. I would appreciate any hints.

#!/bin/bash

# Pin 12 (GPIO18)
CHANNEL=2
CHIP=pwmchip2
PWM=pwm$CHANNEL

echo $CHANNEL > /sys/class/pwm/$CHIP/export
sleep 1
# Servo frequency 50Hz period 20mSec (20,000,000nSec) pulse_width 1.5mSec (1,500,000nSec)
echo 20000000 > /sys/class/pwm/$CHIP/$PWM/period
echo 1500000 > /sys/class/pwm/$CHIP/$PWM/duty_cycle
echo 1 > /sys/class/pwm/$CHIP/$PWM/enable

# Pin 35 (GPIO19)
CHANNEL=3
PWM=pwm$CHANNEL

echo $CHANNEL > /sys/class/pwm/$CHIP/export
sleep 1
# Servo frequency 50Hz period 20mSec (20,000,000nSec) pulse_width 1.5mSec (1,500,000nSec)
echo 20000000 > /sys/class/pwm/$CHIP/$PWM/period
echo 1500000 > /sys/class/pwm/$CHIP/$PWM/duty_cycle
echo 1 > /sys/class/pwm/$CHIP/$PWM/enable

1 Answer 1

1

The Pi5 does have appear to have 4 PWM channels on pwmchip2.
pwmchip0 has 2 of which are accessible on the 40 pin header. It appears only one pair can be activated at a time (unlike earlier Pi).

One (GPIO45) is used for the fan on the fan connector.

I am unaware of any software to use it for any other purpose.

I am still trying to get hardware PWM working on the normal pins.

There are still the emulated PWM; lgpio seems to provide reliable PWM.

1
  • "The Pi5 does have appear to have 4 PWM channels on pwmchip2." - this is what I am also reading. But do you know how to activate all of them? Two are working just fine but I am wondering how to make the other two working?
    – Andrey
    Feb 10 at 10:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.