Accessing Beagle XM I/O expansion pins from Basic
Tank (53) 375 posts |
I thought I’d better remove the LCD connector SWI’s as they kill the display !! |
Neil Fazakerley (464) 124 posts |
Tank, just looking through your source from GPIO v0.15 which I downloaded last night. Your LCD interface list (table 6) shows 30 LCD GPIOs as available. I can only see 27 on the charts in the SRM. You have GPIOs 80, 184 and 187 listed as available on the LCD but there’s no sign of them in my docs. Could it be that one of these ‘extras’ is mapping to pin 18 on the P11 LCD interface – it’s marked as GPIO 170, which enables/disables the DVI-D chip and might account for the display kill that you are seeing. Those three extra GPIOs must be hitting pins on the LCD interface somewhere – chances are one of them must be messing with pin 18. I was playing with some LEDs on the LCD interface a couple of nights ago using bodged up individual register write routines and I don’t remember having any display issues, so I was surprised to see your note above. |
Tank (53) 375 posts |
Page 110 of the SRM shows the GPIO mux for the LCD . It does not list the two I2C3 registers in the mux 4 column. Also DVI_Data10 is actually GPIO_80. GPIO_79 is listed twice! |
Jeffrey Lee (213) 6048 posts |
Yes, the OMAP only outputs the one digital video signal, which gets sent to both the DVI & LCD connectors. So you wouldn’t be able to change the pin mux settings for the LCD pins without affecting the DVI output.
If you can live with the fact that it doesn’t make much of an attempt to fit the image to the screen, then you should be able to get NTSC S-Video output working with the following: *tvout 0 1 0 *tvmode 1 *wimpmode 28 Note that so far I’ve been unable to get PAL output working properly, and if you use 16bpp/32bpp screen modes then the red & blue channels will be swapped. See the wiki page for a bit more info. If you think you’ll find S-Video output useful then let me know and I can have a go at polishing it up a bit. Also, for the IIC port on the expansion header – assuming the pin mux settings are set correctly, you should be able to access them using the revised OS_IICOp interface, by specifying the bus number in the top byte of R1. Since RISC OS numbers them from zero, I2C2 would be bus 1, and I2C3 (for the DVI/LCD connector) would be bus 2. |
Neil Fazakerley (464) 124 posts |
Darn. I must have remembered flashing LEDs on the Aux rather than the LCD connector. I was playing with both at the time, as well as trying to debug my register access routine. I should have studied the schematics in the SRM, then I would have seen it wasn’t worth bothering with the LCD interface. Sorry for giving you a bad steer on that one Tank. Oh well, looks like my robots will have to make do with the camera connector as a sort of runner’s up prize ;-) |
Tank (53) 375 posts |
Dont forget, with a little external logic and latches, you can have almost limitless IO capabilities (Remember Jim, Fred and Sheila on the Beeb?). |
Neil Fazakerley (464) 124 posts |
Talking of speed, I ran a little Basic prog to test the free-running GPIO bit-cycling speed, using GPIO149 (LED0) as a guinea pig test bit. Max toggle rate seems to be about 290kHz on my rev. A2 board. Not bad, but not quite as quick as I’d hoped it would be. (The GPIO module is obviously going to be a fair bit slower with all the extra ops involved – around 46kHz). Also, to achieve maximum speed for a typical 8-bit GPIO port, all 8 chosen bit lines will need to be in the same GPIO module group, otherwise up to 6 separate operations could be needed for each read or write cycle and port speed would plummet accordingly. More crucially though, and regardless of speed, all 8 chosen GPIO lines will need to be in the same module group so that their individual states can be read or written at the same instant, i.e. with a single register op. Otherwise extra hardware buffering and latching of the output will be required for any critical applications. |
Neil Fazakerley (464) 124 posts |
Further to my quest to become a GPIO speed freak, I’ve now managed to squeeze 938kHz continuous read speed and 560kHz write speed out of my XM board, calling assembler LDR/STR fragments from Basic. This is much more respectable timing than my previous effort. Of course, there’s likely to be a slow down once coding to actually use the data is added, but at least it gives some ultimate, perfect-world start point. I would think that really speed critical applications could read/write in bursts to/from buffers and process at leisure later, so those max speeds might be close to achievable in some cases. |
Jeffrey Lee (213) 6048 posts |
Have you considered using any of the other hardware? E.g. I2C, I2S, the UARTs, McBSP, etc. They’re probably a better choice if you want high-speed reliable data transfer. Of course it would require you to have suitable hardware on the receiving end, which may be outside the scope of your project. |
Trevor Johnson (329) 1645 posts |
Neil, this is a little off topic but do you know whether Rob Ward is running RISC OS on any new hardware? (links to Robotics Pages at the bottom of his blog post there) |
Tank (53) 375 posts |
Neil, a couple of test results from my Beagle running at 800Mhz. Simple Basic loop running in a task window using 32 bit wide writes (new in the latest module !!) 81Khz-89Khz Why the bit wide writes from assembler are so much faster is a bit of a mystery… |
Jeffrey Lee (213) 6048 posts |
Did you run those tests with or without the Portable module loaded? Remember that if the Wimp thinks the machine is idle (I think it goes by the number of idle polls per second) then it will try to reduce power consumption by using a combination of reducing the CPU speed and wait-for-interrupt. |
Neil Fazakerley (464) 124 posts |
I can’t say I know what Rob is up to, Trevor. His RISC OS page is dated 2008, so anything could have happened since then. His robotics pages feature Arm Basic code fragments though, so I guess he still feels at home in that medium. |
Neil Fazakerley (464) 124 posts |
OK, Tank, here’s my ‘screaming’ version :) 4.75MHz continuous read speed, 2.42MHz continous write speed. That’s reading/storing or writing (toggling) a GPIO line for 1 second via an assembler loop called from Basic (single tasking). I RMkilled the Portable module beforehand but it only gave a marginal speed up. That’s a x5 speed up on my previous test, so I’d expect the same increase when inserting the GPIO module SWIs in the loop in place of my LDR/STR pairs (haven’t tested the latest version yet). |
Tank (53) 375 posts |
Jeffrey, with the Portable module, after a few seconds the wimp program results will slow down (by a factor of about 10). The Basic loops do not suffer this. A bigger difference is made if other apps are running at the same time. Also, Neil, can you try your test when the other GPIO lines, in the same physical group, are set as output and high out, as that seems to make the difference between my bit wide and 32 bit wide results. It’s almost as if the system polls the high level outputs, so slowing down individual opps. A bit of tweaking to the module and my results are If you don’t mind sending me your test prog, I’ll compare on my board. |
Tank (53) 375 posts |
Some more strange results… Slowing the board clock speed down to 600Mhz makes no little or no difference to the readings. |
Neil Fazakerley (464) 124 posts |
Here’s the Basic prog I’m using to test rough burst speeds, Tank. I have to include a count test inside the assembler to time it as I don’t presently have any physical way (scope etc) to monitor the output frequency directly. Currently I’m getting 2.42MHz (write) and 4.9MHz (read) speeds, but I suspect my figures would be similar to your faster times if I removed the count test: REM Simple read/write routine for Beagle XM single GPIO register MODE MODE A%=&3: B%=mem% + &90 DIM F% 100 DEF PROCassemble |
Tank (53) 375 posts |
OK, Ignore all my previous results !!! Moving my probe to the actual GPIO output shows a better waveform, and clean results. Neil, I can confirm that your prog is indeed running at 2.4Mhz. My results as follows. (consistent over a couple of days now) With the I2C protection on, the speeds are about 15% slower for the bit wide tests. The 32 bit write does not need the protection to work as the I2C lines are not in the same GPIO group on the expansion port. These values do seem more in-keeping with Neils test prog speed as well. Sorry if my previous startling speeds got anyone exited… |
Neil Fazakerley (464) 124 posts |
Thanks to all for pushing this area forward (especially Tank). I’ve uploaded a YouTube video of my XM driving all the GPIO lines on the Expansion port, running a few light-chaser sequences via 22 LEDs just to give the board something to do: http://www.youtube.com/watch?v=RFSCJCbRwcI I found I didn’t need to level shift to drive the LEDs as they are low voltage, low current types that seem happy with the 1.8v available. -Neil F |
Andrew Conroy (370) 740 posts |
That’s brilliant Neil, thanks for that! Loved the chasing LEDs, all you need now is for it to say “Hello Michael”, and you’ve got yourself a Knight Rider board :-) |
Peter van der Vos (95) 115 posts |
Tank, lot of work you did, very nice. |
Tank (53) 375 posts |
Good spot Peter. That serves me right for just copying other sections of code !! Spotted a few others as well… Download updated. Neil, (and others of course) is there any other function that you think would be useful in the module ? |
Peter van der Vos (95) 115 posts |
Tank, if you want to use GPIO pins from a program and use your program to configure it, it would be nice if you can save the configuration from your desktop program and use it with the GPIO module. A GPIO_LoadConfig swi. This way you don’t have to dive into the datasheets to make a program that works with GPIO. |
Tank (53) 375 posts |
Peter, do you mean by passing a pointer to the module that points to a list with entries of GPIO number followed by Mode, O/I, Pull-up/Pull-down flags (as a minimum) ?. |
Peter van der Vos (95) 115 posts |
I think I mean that. The module should have something like:
And you desktop program should have a save button to save a configuration any other program could load and use with GPIO_LoadConfig. |