Hello,
since a time I play around with the GPIO module for BBC BASIC at the pi. As I'am going to read some/all “input GPIO's“ same time, and store the result for later computing: What's the correct syntax? I have tried some of the ...exp32 calls, but get constant failure messages. Read single GPIO works fine. Thanks in advance!
-
- Posts: 1
- Joined: Thu Jan 30, 2014 8:26 pm
- Location: Germany, Lower Saxony
Re: GPIO Read with BASIC
Not sure what you mean by "...exp32 calls" - maybe because I'm 'doin' my own thing' rather than using other peoples' software!
However, I believe this should get you what you want, using a very short bit of assemblerresult% is all the first 32 GPIOs in order, in one 32-bit word.
Using AND and OR appropriately you should be able to dig out of it the GPIOs you want
Beware - I haven't actually used precisely this in anger, although it's the bare bones of what does work in the middle of what I've been writing
However, I believe this should get you what you want, using a very short bit of assembler
Code: Select all
SYS "OS_Memory",13,&20200000,&100 TO ,,,IO_Base%
DIM code% 100
P%=code%
[OPT 2
SWI "OS_EnterOS"
LDR R0,[R0,#&34]
SWI "OS_LeaveOS"
MOV PC,R14
]
A%=IO_Base%
result%=USR(code%)
Using AND and OR appropriately you should be able to dig out of it the GPIOs you want
Beware - I haven't actually used precisely this in anger, although it's the bare bones of what does work in the middle of what I've been writing
Last edited by Burngate on Mon Feb 17, 2014 10:29 am, edited 1 time in total.
Re: GPIO Read with BASIC
I just copied this programme across to the ARMBE (!Edit) Basic Editor on the RC11 RPi. Seems to do something - well it prints a 32-bit number as expected. No I/O connected on my RPi so I've no easy way of knowing if the values are correct.
However, just for those not familiar with BBC Basic.
The line "A% = IO_Base" contains a 'typo', the '%' character is missing.
Should be "A% = IO_Base%",
The '%' character means that the variable 'IO_BASE' is used as a 32-bit integer variable.
Ralph
However, just for those not familiar with BBC Basic.
The line "A% = IO_Base" contains a 'typo', the '%' character is missing.
Should be "A% = IO_Base%",
The '%' character means that the variable 'IO_BASE' is used as a 32-bit integer variable.
Ralph
Re: GPIO Read with BASIC
fladda wrote:The line "A% = IO_Base" contains a 'typo', the '%' character is missing.
Should be "A% = IO_Base%",
The '%' character means that the variable 'IO_BASE' is used as a 32-bit integer variable.


I've put it in now
Re: GPIO Read with BASIC
This small programme gives an excellent example of just how easily and quickly you can get down to almost 'bare metal' programming on the RPi, using RISC OS with its built-in BBC BASIC 
Ralph

Ralph