I am attempting to hook up an analog speaker to my BPI-M2 Zero. For this, I am wanting to use hardware PWM but I cannot get it working. I am currently using Raspbian, but previously tried the latest Ubuntu server and Armbian images which are linked from the Banana Pi wiki.
The gpio command is erroring on any PWM value:
matt@bpi-iot-ros-ai:~$ gpio mode 7 pwm
you choose the hardware PWM:1
matt@bpi-iot-ros-ai:~$ gpio pwm 7 100
val pwmWrite 0 <= X <= 1024
Or you can set new range by yourself by pwmSetRange(range
and I have no /sys/class/pwm - which I suspect may be related to gpio not working for pwm (and why my C# code isn’t working either, as the Microsoft library relies on this)
Here’s the results of gpio readall:
matt@bpi-iot-ros-ai:~$ gpio readall
+-----+-----+---------+------+---+---Pi ?---+---+------+---------+-----+-----+
| BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |
+-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
| | | 3.3v | | | 1 || 2 | | | 5v | | |
| 12 | 8 | SDA.1 | ALT5 | 0 | 3 || 4 | | | 5v | | |
| 11 | 9 | SCL.1 | ALT5 | 0 | 5 || 6 | | | 0v | | |
| 6 | 7 | GPIO. 7 | ALT4 | 0 | 7 || 8 | 0 | ALT4 | TxD | 15 | 13 |
| | | 0v | | | 9 || 10 | 0 | ALT4 | RxD | 16 | 14 |
| 1 | 0 | GPIO. 0 | ALT5 | 0 | 11 || 12 | 0 | ALT4 | GPIO. 1 | 1 | 16 |
| 0 | 2 | GPIO. 2 | ALT5 | 0 | 13 || 14 | | | 0v | | |
| 3 | 3 | GPIO. 3 | ALT5 | 0 | 15 || 16 | 0 | ALT4 | GPIO. 4 | 4 | 15 |
| | | 3.3v | | | 17 || 18 | 0 | ALT3 | GPIO. 5 | 5 | 68 |
| 64 | 12 | MOSI | ALT4 | 0 | 19 || 20 | | | 0v | | |
| 65 | 13 | MISO | ALT4 | 0 | 21 || 22 | 0 | ALT5 | GPIO. 6 | 6 | 2 |
| 66 | 14 | SCLK | ALT4 | 0 | 23 || 24 | 0 | ALT4 | CE0 | 10 | 67 |
| | | 0v | | | 25 || 26 | 0 | ALT3 | CE1 | 11 | 71 |
| 19 | 30 | SDA.0 | ALT4 | 0 | 27 || 28 | 0 | ALT4 | SCL.0 | 31 | 18 |
| 7 | 21 | GPIO.21 | ALT3 | 0 | 29 || 30 | | | 0v | | |
| 8 | 22 | GPIO.22 | ALT3 | 0 | 31 || 32 | 0 | ALT5 | GPIO.26 | 26 | 354 |
| 9 | 23 | GPIO.23 | ALT3 | 0 | 33 || 34 | | | 0v | | |
| 10 | 24 | GPIO.24 | ALT3 | 0 | 35 || 36 | 0 | ALT3 | GPIO.27 | 27 | 356 |
| 17 | 25 | GPIO.25 | ALT3 | 0 | 37 || 38 | 0 | ALT3 | GPIO.28 | 28 | 21 |
| | | 0v | | | 39 || 40 | 0 | ALT3 | GPIO.29 | 29 | 20 |
+-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
| BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |
+-----+-----+---------+------+---+---Pi ?---+---+------+---------+-----+-----+
I tried enabling the pwm overlay in the Raspbian /boot/config.txt, but I don’t really know what I’m doing.
How is hardware PCM configured? Is there an image where it “just works”?