Changing GPIO mode on a Pi4
Andrew Conroy (370) 740 posts |
The SWI GPIO_WriteModenot only allows you to set the pull-up/down resistors, event enable etc., but also allows you to change the mode of a particular pin to any of the alt modes for that GPIO. eg. GPIO 12/13/18/19 can have analgoue audio (of a sort) redirected to them by changing to alt mode 4 or 2 depending on which GPIO. I’ve successfully done this on a Pi Zero, Pi 2B+ and 3B+ in RISC OS, and on a Pi4 from RaspberyPi OS. I can’t, however, do it on a Pi4 from RISC OS as whilst the SWIs appear to work, and reading back the mode tells me that it has been changed, nothing actually appears to happen. Does this need to be done differently on a Pi4 (if so, how?), or is there a bug in the GPIO module meaning changing modes just doesn’t work on a Pi4? |
Andrew Conroy (370) 740 posts |
Does the silence here mean no-one else has tried it, or no-one can replicate the issue? If anyone wants to borrow my PWM Audio board to help find and hopefully fix the issue, let me know. |
Julie Stamp (8365) 474 posts |
I don’t have a Pi 4. Does any mode changing work? E.g. can you change between GPIO and serial port? What mode are you trying to change to (you mention analogue audio – but then PWM?), and what should be happening if the mode change were successful? |
Andrew Conroy (370) 740 posts |
I’ve only tried changing GPIO 12/13 from alt 0 to alt 4, and GPIO 18/19 from alt 0 to alt 2, which redirects PWM audio to those pins. I haven’t tried doing anything serial related as I’m not sure I’d know how to test that. |
Andrew Conroy (370) 740 posts |
Ah, just remembered, the alt modes I’m referring to are the modes you set them to, which don’t actually correspond to the actual alt mode used by the chip: Not that that makes any diference to my problem, but might help clear up any confusion(!) |
Timo Hartong (2813) 204 posts |
Hi also the gpio command on the Pi 400 has its problems so I’m not amazed that RISC-OS is a bit behind ;-) |