log in | register | forums
Show:
Go:
Forums
Username:

Password:

User accounts
Register new account
Forgot password
Forum stats
List of members
Search the forums

Advanced search
Recent discussions
- Archive Edition 27:2 reviewed (News:)
- WROCC May 2024 meeting - Gerph talks games (News:)
- Drag'n'Drop 13i3 edition reviewed (News:1)
- Wakefield Show 2024 in Pictures (News:5)
- April 2024 News Summary (News:2)
- RISC OS 5.30 arrives (News:2)
- Upgrading your RISC OS system to 5.30 (News:2)
- WROCC May 2024 meeting on wednesday - Gerph talks games (News:)
- uniprint upgraded to 4.50 (News:)
- PhotoDesk 3.23 released (News:)
Latest postings RSS Feeds
RSS 2.0 | 1.0 | 0.9
Atom 0.3
Misc RDF | CDF
 
View on Mastodon
@www.iconbar.com@rss-parrot.net
Site Search
 
Article archives
Acorn Arcade forums: Programming: Serial port problem in BASIC
 
  Serial port problem in BASIC
  winterhunter (17:36 13/3/2008)
  andy_s (22:03 3/6/2009)
    arawnsley (23:05 3/6/2009)
 
Gonzalo Meza Message #106749, posted by winterhunter at 17:36, 13/3/2008
Member
Posts: 105
Hi everyone,

I'm trying to communicate with a PIC microcontroller using RS-232, and
I'm the testing phase using a null modem cable to connect to my PC.

For information, I~m trying to run this on an Iyonix, and using the DrWimp package.

The code successfully sends data, but refuses to quit the loop because
of char<>0. I'm certainly missing something silly, so can anyone have
a quick look at it,please?

[snip]
PROCinit_serial
PROCsend_cmd(66)
NULL%=TRUE
ENDPROC
:
DEF PROCinit_serial
SYS"OS_SerialOp",0,180,0
REM Set data format to 8N1
SYS"OS_SerialOp",1,0
REM Set receive baud rate to 9600
SYS"OS_SerialOp",5,7
REM Set send baud rate to 9600
SYS"OS_SerialOp",6,7
ENDPROC
:
DEF PROCsend_cmd(cmd)
LOCAL n,char,tmp
SYS"OS_SerialOp",3,cmd
n=0
REPEAT
n=n+1
SYS"OS_SerialOp",4,0 TO tmp,char
UNTIL (n=1000000) OR (char>0)
PROCwimp_puticontext(main%,3,STR$char)
ENDPROC
:

One more question: How do you use inline assembler in Basic code?

Thanks a lot!

--
Gonzalo Meza
  ^[ Log in to reply ]
 
Andy Stringer Message #110188, posted by andy_s at 22:03, 3/6/2009, in reply to message #106749
Member
Posts: 13
Hi,

I haven't got an Iyonix and I've not been able to try out your code, but I've had a look in my RISC OS 3 PRMs.

The only things I spotted that you could check were firstly in:

SYS"OS_SerialOp",0,180,0

You're passing binary 10110100 into R1.
No idea if it's still the case on your system but my PRM says setting bit 1 to 0 means "Use the ~DCD bit". Now I've no idea what the ~DCD bit is but my manual says "if a character is received when ~DCD is high, then cause a serial event, and do not enter the character into the buffer.". Is this what you intended?

The other thing my RISC OS 3 PRM says is that for OS_SerialOp 4 to have any effect, OS_Byte 2 must first be used to enable reception. Try adding the line
SYS"OS_Byte",2,1
just before your loop.

As for inline assembler in BBC BASIC, I think you just stick it in square brackets where you want it to run. You can pass data into the registers using the native variables - R0 is A%, R1 B% etc I think.

Have a look at this http://foundation.riscos.com/html/features/03/assem/intro.htm#BasAssm

Cheers,

Andy.
  ^[ Log in to reply ]
 
Andrew Rawnsley Message #110189, posted by arawnsley at 23:05, 3/6/2009, in reply to message #110188
R-Comp chap
Posts: 595
I know when I did DialUp32, the serial port didn't wake up properly unless the modem was turned on when the computer started up. If it was on, the port seemed to "initialise" and could then be used. If the modem wasn't on at startup, there was no response from the serial port, even if the modem was on *now*.

Not sure if this is helpful/relevant, but I don't think it was ever fixed.
  ^[ Log in to reply ]
 

Acorn Arcade forums: Programming: Serial port problem in BASIC