GPIO and BBC Basic
Norman (1860) 29 posts |
I have searched the BBC Basic manual for various terms which I hoped would allow me to read the GPIO pins on my Pi but cannot find anything. |
Wouter Rademaker (458) 197 posts |
see: http://www.riscosopen.org/forum/forums/5/topics/1445 and to plug a program I made: http://www.egel.org/drupal/software/RISC_OS LedBorg |
Norman (1860) 29 posts |
Thanks Wouter That will surely get me started. |
neil.r (1738) 66 posts |
There’s also some info on the r-pi forum: http://www.raspberrypi.org/phpBB3/viewtopic.php?f=55&t=22250 I started converting the Gertboard demo programs to BASIC, but haven’t made great progress so far. What I have can be found at http://www.ronketti.org.uk/ if you’re interested. I’ve reached a bit of a stopping point now with the motor control stuff, as I need to utilise PWM, and for that, I need greater than the centisecond precision that BASIC allows. So, I guess I need to learn ARM assembler – which is a Good Thing to do anyway, so I may as well get on with it. Ta, |
E.W. Faircloth (1905) 1 post |
Somewhere I read that you could go into supervisor mode and do short amounts of work. So I tried to do that with the SWI OS_EnterOS and OS_Exit. Nothing happened. What am I doing wrong? With the arm2008 toolchains GNU assembler: To turn on an LED on pin#17 all one has to do is write a 1 to bit 21 of Pi GPIO base+4. Next, write a 1 to bit 17 of Pi GPIO base +40. My code uses A% as base address &20200000. B% is 1 written to bit 21 of R1, and C% is 1 written to bit 17. Here’s my code on the Pi running RISCOS. It goes into assembly and exits but nothing happens to the LED on pin #17. If I use Tank’s module I can get the LED to light up so I know it works, just not with my code. What am I doing wrong? 10 REM > ASM Yes, I could use Tank’s module as it works well but I want to be able to do this with a few lines of assembly code. Tank’s GPIO is a Swiss army knife with error checking. I want to be able do what I’ve done using another assembler. Being a retired photographer and non-programmer, being able to work in BASIC appeals to me. I was able to use arm2008q3 assembly language to control GPIO pins for a project, http://www.faircloth.org/blog1/?p=7319, and want to be able to do the same time with BASIC with assembly routines. The routines are listed here, http://www.faircloth.org/blog1/?p=7337 If I can just get ove the initial hump using the RISCOS assembler, I may be on my way:) |
Neil Fazakerley (464) 124 posts |
@ EW Faircloth The GPIOs are memory mapped under Risc OS. That means you can’t access the BCM2835’s registers directly (which is what your code tries to do). You first need to find out what memory location Risc OS has assigned to the Pi’s GPIO registers – only then can you go ahead and bit bash those locations in assembler. I knocked up a bit of BASIC code a while back to see how quickly I could toggle a GPIO output on and off and how quickly I could read an input. You may find some of it adaptable to your purposes: MODE MODE: OFF DEF PROCassemble |