Pi GPIO - PWM Pins
Chris Johns (8262) 242 posts |
A quick question, but is there a way to control the ‘hardware’ PWM on the Pi’s GPIO pins? I can set it to PWM mode, but GPIO_Write seems to have no effect. If I set the pin to GPIO mode I can turn it off and on manually, but I don’t really want to so software PWM. Cheers Chris |
Rob Andrews (112) 164 posts |
Hi Chris a quick question can Python 3.10.0a5+ load pyserial? and if it can how do i load it |
Andrew Conroy (370) 725 posts |
Are you trying this on a Pi3 or a Pi4? As far as I can see, changing mode is broken to some extent in RISC OS on the Pi4. I’ve been trying to change the mode of pins to redirect pwm audio out via the GPIO. This works fine on all earlier versions of the Pi but not on the Pi4 using RISC OS. I can do it from Linux, so the hardware still supports it. |
RMAC Harvey (9300) 8 posts |
This is a very interesting thread not least because I have a stash of modules, HATs, servos etc that I have bought very recently and would like to bring to life using BASIC if possible.
Regarding the second option… Can we communicate via the 12C on BBC BASIC? I guess the goal would be to mimic the signal the code creates would it be possible technically? PS my misuse of the english language is, although prevalent, unintentional |
Alan Adams (2486) 1140 posts |
Yes. I do it to talk to an IIC – 1-wire adapter. The IIC bit was easy, the 1-wire part more tricky. The program is here: http://www.adamshome.org.uk/RiscOS/templogger.zip The bit you probably want is called onewirelib. It uses the older IIC_Control SWI. The IIC_Op SWI is preferred, but it made it more difficult to debug the one-wire bots. The older interface does things one step at a time. The newer one stacks things into groups. |
Chris Johns (8262) 242 posts |
I’ve started having another look at 3.10, so tried pyserial. It seems that out of the box it doesn’t work because it doesn’t know how to handle RISC OS serial ports – fair point I guess. I’m not sure what would be involved in making it work, either by DeviceFS (which would proably be easiest and would handle at least USB serial devices) or with the block drivers. From memory, the block drivers involve loading a chunk of code into your own program and calling it via an entry point. I’m not sure python can do this as it stands – although it could probably be made to do so via a C veneer. |