GPIO Audio on the Pi4/400
Andrew Conroy (370) 740 posts |
I’ve mentioned this before, but I’m still struggling with it. If you change the mode of GPIOs 12/13 or 18/19 you can redirect the audio that would have gone to the headphone socket to these pins instead. All that’s needed is:
For GPIOs 12/13 replace the 2 with 4 (alt mode 0). On the Pi 2/3/Zero this works fine, and I have a small board which plugs into GPIO and provides a headphone socket – perfect for a PiZero if your monitor doesn’t support HDMI audio (mine doesn’t). On the Pi4 or Pi400 this doesn’t work. I raised it as a bug but Sprow assures me that changing GPIO mode does work correctly. Therefore, it must be me doing something stupid as I still can’t get a squeak from the GPIO pins. Can anyone suggest what I’m obviously doing wrong? I’m not a “proper” programmer, and I only dabble in BASIC I’m afraid so “real” programmers feel free to turn away now! I can change the GPIO mode and generate audio via the GPIO pins from RaspberryPi OS, which would suggest that the fuctionality is still there. Page 99 of the BCM2711 ARM Peripherals manual suggests that GPIO12/13 still has PWM0 at alt mode 0 and GPIO 18/19 has it at alt mode 5, the same as previous versions of the Pi. If necessary, I’m happy to loan someone my little audio board if needed for testing purposes. |
Rick Murray (539) 13851 posts |
I recall that analogue audio on the Pi is implemented via an interesting hack with a modulated PWM output. |
Andrew Conroy (370) 740 posts |
Yes, that’s right. I can change the GPIO mode and generate audio via the GPIO pins from RaspberryPi OS, which would suggest that the fuctionality is still there. Well, it’s certainly present when using RaspberryPi OS, so that would suggest that RISC OS is doing something that prevents/doesn’t enable this on the Pi4/Pi400. |
Andrew Conroy (370) 740 posts |
Anyone else any suggestions for what I’m doing wrong? I’d like to hear my Pi400 go beep from RISC OS, not just RaspberryPi OS! |