PWM on a Banana Pi M1

While waiting for CAN bus transceivers, here’s how to enable PWM on the Banana Pi M1. There’s 2 PWM pins: one is used for the internally connectable LCD (PWM0), and the other one (PWM1) is available on the 26 pin GPIO list (pin 7, PI3)

Enable in /boot/armbianEnv.txt:

overlays=pwm
param_pwm_pins=both

To enable and use:

cd /sys/devices/platform/soc/1c20e00.pwm/pwm/pwmchip0
# use 1 to export PWM1, and 0 to export PWM0
echo 1 > export
# After enabling export, there's a new directory:
cd pwm1
# All times in ns
echo 1000000 > period
echo 300000 > duty_cycle
echo 1 > enable

and you get a 30% off, 70% on PWM with 1kHz.

I am assuming a recent Armbian, e.g. from November 2023 (kernel 6.1.63).

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.