Pi GPIO in RISC O/S
John Martin (8723) 8 posts |
Can I ask a really simple question? |
Chris Hall (132) 3554 posts |
I want to write a relatively simple program on a Pi in RISC OS BASIC which uses the GPIO pins Use the GPIO module. It is in ROM. For example:
|
John Martin (8723) 8 posts |
Chris |
Timo Hartong (2813) 204 posts |
Just go to the command line or open an command window ( use F12 or Crtl – F12 ) and type FX 0 . Or look at info in the RO icon on the bar on the right side |
John Martin (8723) 8 posts |
Thank you Timo. I have Version 5.21 dated July 2013 |
Stuart Painting (5389) 714 posts |
The GPIO module wasn’t added to RISC OS until 2014. I suggest you download the latest stable release of RISC OS and write it to a new SD card: the easiest way of doing this is to use Raspberry Pi Imager – select “RISC OS” as the operating system. |
John Martin (8723) 8 posts |
Thank you Stuart. It solves that issue. I’ll reload with the current version of RISC OS. |
John Martin (8723) 8 posts |
My SD card with 5.28 arrived this morning and I installed it in my Pi. Opening Utilities.!Manual.Root showed that there are now entries for GPIO. Excellent. Opening the GPIO primer appeared to give me step by step instructions of how to use it. Excellent. However, the first step is “check the module is loaded”, with some alternative ways of finding out. I assumed everything associated with the OS is on the card I just bought and was loaded as part of the OS. Can you tell me what is “the module”, where do I find it and how do I load it? It might be a good idea to add these missing details to the manual. |
Timo Hartong (2813) 204 posts |
In 5.28 the module is standard available. The text from the primer needs some updating ;-) |
John WILLIAMS (8368) 493 posts |
Here it’s the last ROM module, number 136, as displayed by Verma, though the internal web link for that appears to be broken. A quick search finds it here Lenny seems to have changed his index page! |
Alan Adams (2486) 1149 posts |
*modules here on rPi shows it at number 128, RO5.28 |
John WILLIAMS (8368) 493 posts |
Sorry, mine’s 5.29. |
Rick Murray (539) 13840 posts |
Wow, who made that mess? Looks like the zip might have been created on a Mac (a subfolder in archive root called __MACOSX with metadata within is a clue!) , hence no filetypes at all. Types are: !Boot / !Run – Note – if setting the type via Filer, you can drop the leading ‘&’ and it’ll still work. |
John WILLIAMS (8368) 493 posts |
Opened a can of worms there, didn’t I! And I was only trying to be helpful! My archived archive is fine! |
John Martin (8723) 8 posts |
Thanks Timo, I still cannot find !GPIOMachine but the code that Chris Hall sent me now runs, so I guess all is well. Thank you all for your help. |
John Martin (8723) 8 posts |
You seem to drifted off the subject a bit. Based on what Chris sent me a while ago and the information in the StrongEd guide, I expected to be able to do what I want, but I am still lost. There is lots of information but it just confuses. All I want to do is set a number of pins up so I can switch them off and on, and set another couple pins so that I can read whether they are on or off from an external source. Could some kind soul help this senile old codger and write down the syntax for the 6 read and write SYS commands that seem to be associated with trying to do this. Prior to trying to use RISC OS for my project, I had used “Return to Basic” which does the same thing in a wonderfully simple way. Incidentally, whenever I log into this site, it rejects my password, though I know it is right. Does anyone else have this problem? |
Chris Hall (132) 3554 posts |
Try this:
Can you tell me what is “the module”, where do I find it Try here (it’s the last module listed in the ROM). |
Julie Stamp (8365) 474 posts |
I’ve setup a wiki page. Please can someone tell me if it works on Pi 4 or Pi 400? I still am not clear whether GPIO is possible at all on those! |
Andrew Conroy (370) 740 posts |
Broadly, GPIO works on the Pi4/Pi400 if you’re flashing LEDs etc., but the GPIO_WriteMode SWI doesn’t appear to allow you to change from GPIO (default) to another mode eg. PWM. On the Wiki page you refer to GPIO pins rather than GPIO numbers. It’s confusing, but GPIO 25 is not pin 25 but pin 22. As the GPIO module works from GPIO number rather than pin number, it might be sensible to refer to GPIO numbers rather than pins. There’s lots of diagrams out there showing physical pin number and GPIO number too, hopefully one of them will have a suitable licence to allow it to be either copied or linked from the Wiki. |
Julie Stamp (8365) 474 posts |
It is :-/ I’ve tried to square the BCM2835 peripherals table up with GPIO_Info, but I can’t match it up.
There’s not even the same number of modes :-( We could link to this, but again I don’t understand how the alternative function information relates to what the GPIO module says. |
Andrew Conroy (370) 740 posts |
You have to look at the Legacy section of the StrongHelp Manual to find what the mode numbers for Read/WriteMode mean: and then look at the BCM2835 (or whatever Pi you have) to see what each Alt mode corresponds to for each GPIO! eg. alt 0 (so Mode 4) for GPIO 12 & 13 is PWM, which redirects the audio PWM signal to GPIO 12/13 instead of to the headphone socket, or at elast it does on earlier Pi’s, it appears to be broken on the Pi4/400 under RISC OS (I can do it from RaspberryPi OS). |
Julie Stamp (8365) 474 posts |
I found the Pi 3 modes were fixed in August, so I need to use a newer HAL. |
John Martin (8723) 8 posts |
Thank you again Chris. Is there any reason why you have written a PROC for inputs but not outputs? Thank you to everyone else for your contributions Andrew, if you use Return To Basic there is another set of pin numbers associated with WiringPi, just to confuse you some more. |
Andrew Conroy (370) 740 posts |
Yes, I’ve seen those, but prefer not to mention them so I might forget they exist! How many numbering schemes do we need? |
Steve Pampling (1551) 8170 posts |
That’s probably the first time in years that I’ve seen “pin numbers” used in a non-tautological context. On topic, it seems like people are describing the re-arrangement of GPIO pin use on Pi boards as an almost random item. Why isn’t everything the same on every model of Pi? |