Accessing Beagle XM I/O expansion pins from Basic
|
First of all, is this possible with the current ROM port? Secondly, how would I go about setting up something similar to an RPC parallel port without resorting to assembler etc. Can it all be done with SWIs? Are the GPIO pins and registers all memory mapped and therefore programmable – like a cross between parallel printer port control registers and the old 1MHz bus? My interest lies in control and monitoring of external hardware like stepper and servo motors, relays, sensors etc and I’d like to see my XM doing some kinetic work. -Neil F. |
|
The pins and registers are memory mapped, but accessing them from BASIC without using assembler will be a bit tricky with the current ROM image. There’s also nothing in place to stop you from accidentally modifying pins which are already in use by something else, nor is there any code to switch between the different pin mux settings for the expansion header (If you look in the XM manual then you’ll see that there are 4 different basic configs to select which pins are available on the header). At some point I guess we should add some kind of GPIO manager module to make all of the above easier, but I’ll admit that it’s not something that’s particularly high up my list of priorities. |
|
Ah, my reply was before I’d read this one. |
|
Thanks Jeffrey. Oh well, looks like the trusty old Risc PC wins again (no wonder they’re going up in price). Iyonix hardware is too flakey – I’ve had two motherboards fail on me now – and has no direct I/O lines available, so it’s back to the old tech again. |
|
If you want a small module to access registers in could make one. This way it would be possible to access registers from Basic. It would be simple and no ‘manager’. Just raw access to test things. |
|
OK, couldn’t resist. |
|
Wow Peter, that was quick service, thanks! I’ll have a play and see where I get to. -Neil. |
|
Peter, I think you should access the registers with bit wide data only. So… I’ve stolen your source and made a module that works bit wide. |
|
Tank, no problem using the code. That why I put it there :-) |
|
I’ve added a few more bits to Peters module. |
|
Many thanks for your input, Tank – and not for the first time on my behalf, ISTR ;) I’m still digesting the relevant sections in the XM manual, but no doubt I’ll be back soon with more questions. |
|
I’ve done a bit more work on the module, and also created an app to display and control the state of the AUX and EXP pins. |
|
Tank, |
|
No, its the toolbox…..ProgInfo module…. Done now !! |
|
A new version of the module. I’ve made the SWI interface simpler, as now you only need to send the GPIO number to the module to control the pin. (Note, please remember this only works on the Xm board ATM). |
|
Peter, is this module registered ? If not, I’ll send a request in… |
|
No, the swi base is not registered. I think it uses an older number we registered before (+64) or something like that. |
|
Ahem! |
|
Ahem! I know, but it was for testing only. Now I/Tank will request a real swi-base. |
|
For reference, |
|
Thanks for this, I’m sure people will find it very useful! All we need now is to be able to access the IIC port on the expansion header too and we’ll be fully set up to interface to the outside world in whatever way we like :-) |
|
Well, the I2C2 port is on pins 23 and 24 and the pins need to be set as mode 0. (these are GPIO 183,168 in mode 4) |
|
Module now registered and updated !! |
|
Crikey Tank, that was quick, I can’t keep up with these releases :-) I’ve tested LEDs on various outputs in the main and aux ports with the earlier version and all seemed fine. Not tried any inputs yet as I’m waiting for some level shifters to suit my gadgets. I guess I could just try switches though. |
|
That’s good to know Neil… |