RISCPC accessing parallel port in BASIC

Discuss all aspects of programming here. From 8-bit through to modern architectures.
Post Reply
User avatar
sydney
Posts: 2228
Joined: Wed May 18, 2005 9:09 am
Location: Newcastle upon Tyne
Contact:

RISCPC accessing parallel port in BASIC

Post by sydney » Fri May 11, 2018 10:55 am

The RISCPC has a bidirectional parallel port so I was hoping to do a bit of interfacing with arduinos or raspberry pi's with it. Is it possible to access the parallel port from BASIC or will I need to learn arm assembler?

RobC
Posts: 2300
Joined: Sat Sep 01, 2007 9:41 pm
Contact:

Re: RISCPC accessing parallel port in BASIC

Post by RobC » Fri May 11, 2018 11:50 am

Have to admit that this isn't something I've done but the RISC OS Programmer's Reference Manual suggests that the Parallel_Op SWIs allow you to access the parallel port registers. You can access the OS SWI calls from BASIC using the SYS command.

User avatar
sydney
Posts: 2228
Joined: Wed May 18, 2005 9:09 am
Location: Newcastle upon Tyne
Contact:

Re: RISCPC accessing parallel port in BASIC

Post by sydney » Fri May 11, 2018 12:39 pm

RobC wrote:Have to admit that this isn't something I've done but the RISC OS Programmer's Reference Manual suggests that the Parallel_Op SWIs allow you to access the parallel port registers. You can access the OS SWI calls from BASIC using the SYS command.
I'd read that page but was unsure how to use OS SWI calls. Trying to run before I can walk!

RobC
Posts: 2300
Joined: Sat Sep 01, 2007 9:41 pm
Contact:

Re: RISCPC accessing parallel port in BASIC

Post by RobC » Fri May 11, 2018 3:02 pm

There's some info on how to use the SYS command here.

From memory, it's fairly straightforward once you get used to it but it's years since I did any serious BASIC programming on RISC OS.

Might be worth playing with something like OS_Plot just to get started as it's like using the BASIC PLOT command.

sirbod
Posts: 876
Joined: Mon Apr 09, 2012 8:44 am
Location: Essex
Contact:

Re: RISCPC accessing parallel port in BASIC

Post by sirbod » Sat May 12, 2018 6:00 am

From a brief look at the Parallel_Op documentation, I'd say you use Parallel_Op 2 to set the direction, then Parallel_Op 0 to read or Parallel_Op 1 to write.

User avatar
jgharston
Posts: 3212
Joined: Thu Sep 24, 2009 11:22 am
Location: Whitby/Sheffield
Contact:

Re: RISCPC accessing parallel port in BASIC

Post by jgharston » Sat May 12, 2018 9:46 am

Something like:
SYS "Parallel_Op",2,0,NOT 32:REM Set as output
SYS "Parallel_Op",1,data:REM Write to parallel port
:
SYS "Parallel_Op",2,32,NOT 32:REM Set as input
SYS "Parallel_Op",0 TO ignore,data,status:REM Read from parallel port

The documentation doesn't actually say which way about bit 5 is to set input or output, so SYS "Parallel_Op",2,0,NOT 32 and SYS "Parallel_Op",2,32,NOT 32 may be the wrong way around.

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.25
(C) Copyright J.G.Harston 1989,2005-2015
>_

Post Reply