Accessing Beagle XM I/O expansion pins from Basic
Neil Fazakerley (464) 124 posts |
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. |
Jeffrey Lee (213) 6048 posts |
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. |
Dave Higton (281) 668 posts |
Ah, my reply was before I’d read this one. |
Neil Fazakerley (464) 124 posts |
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. |
Peter van der Vos (95) 115 posts |
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. |
Peter van der Vos (95) 115 posts |
OK, couldn’t resist. |
Neil Fazakerley (464) 124 posts |
Wow Peter, that was quick service, thanks! I’ll have a play and see where I get to. -Neil. |
Tank (53) 375 posts |
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. |
Peter van der Vos (95) 115 posts |
Tank, no problem using the code. That why I put it there :-) |
Tank (53) 375 posts |
I’ve added a few more bits to Peters module. |
Neil Fazakerley (464) 124 posts |
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. |
Tank (53) 375 posts |
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. |
Peter van der Vos (95) 115 posts |
Tank, |
Tank (53) 375 posts |
No, its the toolbox…..ProgInfo module…. Done now !! |
Tank (53) 375 posts |
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). |
Tank (53) 375 posts |
Peter, is this module registered ? If not, I’ll send a request in… |
Peter van der Vos (95) 115 posts |
No, the swi base is not registered. I think it uses an older number we registered before (+64) or something like that. |
Steve Revill (20) 1361 posts |
Ahem! |
Peter van der Vos (95) 115 posts |
Ahem! I know, but it was for testing only. Now I/Tank will request a real swi-base. |
Tank (53) 375 posts |
For reference, |
Andrew Conroy (370) 740 posts |
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 :-) |
Tank (53) 375 posts |
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) |
Tank (53) 375 posts |
Module now registered and updated !! |
Neil Fazakerley (464) 124 posts |
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. |
Tank (53) 375 posts |
That’s good to know Neil… |