RS423 serial port question with no handshake

for bbc micro/electron hardware, peripherals & programming issues (NOT emulators!)
Post Reply
User avatar
PitfallJones
Posts: 433
Joined: Fri Feb 22, 2008 3:44 pm
Contact:

RS423 serial port question with no handshake

Post by PitfallJones » Fri Mar 17, 2017 2:49 pm

Hi,

I've been experimenting with using the BBC serial port communicating to and from a PC.

I have Sprows BBC to DB9 serial cable that I believe swaps the CTS/RTS lines.

With handshaking on that works brillantly in that sending and receiving work fine.

With handshaking off however sending data from the BBC doesn't work (receiving is fine).

I'm using OSBYTE 138 to send like:

Code: Select all

70 A%=138:X%=2
80 IF ADVAL(-1)>0 AND ADVAL(-3)>0 THEN Y%=GET:CALL&FFF4
I can tell nothing gets sent as looking at ADVAL(-3) is showing the transmit buffer filling up but not emptying.

So .... is there any *FX call I can make to get the BBC OS to ignore handshaking and not wait on a correct CTS signal?

I'm going to try to make myself up a serial cable where I loop back the RTS line to the CTS input on the BBC side (I'm waiting on one of those !very rare! 5 pin domino din plugs in the mail at the moment....)

In the meantime I was wondering if there is a software solution?

Thanks

PJ

cmorley
Posts: 610
Joined: Sat Jul 30, 2016 7:11 pm
Location: Oxford
Contact:

Re: RS423 serial port question with no handshake

Post by cmorley » Fri Mar 17, 2017 3:42 pm

Hi,

Do you mean you turned CTS/RTS handshaking off at the PC end?

I don't think you can turn it off at the BBC end and use the OS to send stuff can you? What's the osbyte call for that?

So I'd imagine that the Beeb is waiting for CTS to be asserted from the PC so the beeb never sends anything. Write directly to the ACIA register and see if things come out then (?&FE09=n from BASIC). If you want to write directly you /ought/ to check the status to see if the output buffer is clear to accept data, but as a test it works.

Out of interest why do you wish to turn off handshaking? I use a CTS/RTS serial cable to connect to a modern PC @ 38400 (6850 is fine for it) with CTS/RTS handshaking on. Both for "*fx2,1 & *fx3,5" remote control and for binary transfer from the compiler setup on my PC (I get 3.8kB/s with an ASM reciever loop on the beeb).

Chris

User avatar
PitfallJones
Posts: 433
Joined: Fri Feb 22, 2008 3:44 pm
Contact:

Re: RS423 serial port question with no handshake

Post by PitfallJones » Fri Mar 17, 2017 4:42 pm

Do you mean you turned CTS/RTS handshaking off at the PC end?
Yes
I don't think you can turn it off at the BBC end and use the OS to send stuff can you? What's the osbyte call for that?
Well the only call I could find is 138 and I think that is handshake only (unless there is some other call that changes that behavour)
So I'd imagine that the Beeb is waiting for CTS to be asserted from the PC so the beeb never sends anything. Write directly to the ACIA register and see if things come out then (?&FE09=n from BASIC). If you want to write directly you /ought/ to check the status to see if the output buffer is clear to accept data, but as a test it works.
Thanks for the tip - I'll try that - The data sent from the BBC to the PC will only be at typing rates by the way.
Out of interest why do you wish to turn off handshaking?
Well what I'm actually trying to do is get the BBC to communicate with a serial to wifi device (not a PC) so I can connect the BBC to the internet.
See this thread: http://www.stardot.org.uk/forums/viewto ... =3&t=12426

To that end I've got the PC succesfully communicating with the device, althought the device is only reliable with handshaking turned off when talking to the PC so that's why I need handshaking off when connecting it to the BBC instead of the PC.

The proceedure is send AT+ 'GET' command to the device then receive the web page back from device.
That works fine with the device connected to the PC without handshaking. With handshaking it freezes up for some unknown reason.
When connected to the BBC the device never gets the AT+ command as the BBC never sends it.....(due to the original issue).
I get 3.8kB/s with an ASM reciever loop on the beeb).
I found the same thing with other serial tests in that the BBC's basic is too slow to receive all the characters but a machine code loop worked fine (at 9600 and 19200 baud)

PJ

cmorley
Posts: 610
Joined: Sat Jul 30, 2016 7:11 pm
Location: Oxford
Contact:

Re: RS423 serial port question with no handshake

Post by cmorley » Fri Mar 17, 2017 5:26 pm

I don't think you can turn it off at the BBC
I should have written, "I am almost certain you can't turn it off at the BBC".

You can test the ACIA status from BASIC too by reading from the status port at S%=?&FE08. Bitwise AND with 2 to get the transmit buffer empty flag. There is little point though because BASIC is so slow it will probably always be empty! The transmit is double buffered in the 6850 so it can be serialising and accept a new character concurrently.
BBC to communicate with a serial to wifi device
Cool. Sounds fun. In that case definitely turn off handshaking and just short CTS & RTS in your plug as you suggested in your original post!

As an aside, if the module acts similar to a modem with an AT command set maybe it expects DSR/DTR style flow control like PC modems in the 90/00s did? (RS232 pinouts notwithstanding, Putty will do CTS/RTS and DSR/DTR hw flow control).
BBC's basic is too slow to receive all the characters
The OS will receive them all at 38400 and buffer them if you use *fx203,32 (send buffer full 32 chars from the buffer end). By the time the PC stops sending you won't have overflowed. The caveat being if you issue a command which keeps interrupts disabled for a long time you will may drop some. Also if you turn off screen/RS423 echoing with *fx3,n then BASIC will parse the input at a pretty good lick too (dog slow if you leave *fx3,5 on!).

Chris

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

Re: RS423 serial port question with no handshake

Post by jgharston » Fri Mar 17, 2017 6:08 pm

I'm fairly certain you can't program the 6850 to do "send data without waiting for receiver to say "GO"'. It's not the BBC not ignoring handshaking, it's the hardware not ignoring handshaking. If the receiver is saying "WAIT" the 6850 will do as it's told and wait. What you would have to do is modify your serial lead and connect CTS to 0v so it is premanantly strapped to "GO".
This is what you can physically get the hardware to do:

Code: Select all

+--------+----------------------------+------------------------------+
|        |           Write            |            Read              |
+========+============================+==============================+
| base+0 |          Control           |           Status             |
|        | b7: Enable receive ints    | b7: Interupt Request         |
|        | b6: RTS low/high           | b6: Receive Parity Error     |
|        | b5: Enable transmit ints   | b5: Receive Data Overrun     |
|        |   b6-5=11: Break           | b4: Framing Error            |
|        | b4: 7bit/8bit data         | b3: Clear To Send not present|
|        | b3: 2/1 stop bits          | b2: DCD not present          |
|        |   b4-3=10: No parity       | b1: Transmit Register Empty  |
|        | b2: even/odd parity        | b0: Receive Register Full    |
|        | b1-0: Clock divide 1/16/64 |                              |
|        |   b1-0=11: Reset           |                              |
+--------+----------------------------+------------------------------+
See. There's no "ignore CTS". All there is is "tell sender to WOAH!" (raise/lower RTS).

Fundamentally, the thing you've got at the other end is broken. It should be raising/lowering CTS correctly.

Code: Select all

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

cmorley
Posts: 610
Joined: Sat Jul 30, 2016 7:11 pm
Location: Oxford
Contact:

Re: RS423 serial port question with no handshake

Post by cmorley » Fri Mar 17, 2017 7:10 pm

The 6850 does not perform the handshaking. It does have the extra inputs and outputs to allow hardware handshaking - which refers to the extra wires for flow control not that it is handled in hardware. This is in contrast to "software" flow control which only has RX,TX & GND connections and sends start/stop characters. The actual flow control logic is still done by the computer OS/firmware in both "software" and "hardware" flow control.

If you connect a scope to a BBC's serial port TX with nothing else connected and run:

Code: Select all

10 ?&FE09=65
20 GOTO10
It will merrily spit As (65) out of the TX pin.

Wheras

Code: Select all

10 *FX138,2,66
20 GOTO10
Will not spit out any Bs (66) unless RTS & CTS are shorted and the beeb is asserting RTS (*FX2,1 will do that).

Chris

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

Re: RS423 serial port question with no handshake

Post by jgharston » Fri Mar 17, 2017 7:42 pm

Yes, the OS buffer manager does (effectively):
.loop
LDA status
AND #TxReady ; Is interface ready for transmission? Ie, is CTS ok and TxData empty?
BNE loop
STX data

whereas just stuffing data just does:
STX data ; Don't care if CTS is ok or TxData is empty

Some ACIAs have a seperate TxRDY and TxEmpty signal in the status register so you can do a clean transmit with no CTS by just testing TxEmpty instead of TxReady (eg 2681)

Code: Select all

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

User avatar
PitfallJones
Posts: 433
Joined: Fri Feb 22, 2008 3:44 pm
Contact:

Re: RS423 serial port question with no handshake

Post by PitfallJones » Sat Mar 18, 2017 2:01 am

Thanks so much Guys!

The Magic command is ?&FE09=Y%

With that I've finally got a response from the Device - so stay tuned as I attempt to get it doing something useful!

PJ
Last edited by PitfallJones on Sun Mar 19, 2017 10:06 pm, edited 1 time in total.

User avatar
PitfallJones
Posts: 433
Joined: Fri Feb 22, 2008 3:44 pm
Contact:

Re: RS423 serial port question with no handshake

Post by PitfallJones » Sun Mar 19, 2017 9:56 pm

Hi,

Thanks again for all the help - I discovered in the end my Wifi Device didn't actually support handshaking after all - the manual mentions it doesn't even when it's web interface suggests it should.

Anyway by setting $FE09 directly and adding a suitable delay sending commands to the device worked perfectly and HTML pages are returned to the BBC Micro!

Code: Select all

8300 .send
8310 LDX#0
8320 .sendloop
8400 LDA text,X
8402 BEQ sendexit
8410 STA &FE09
8411 STA &7C00,X
8420 JSR delay
8430 INX
8440 JMP sendloop
8445 .sendexit
8450 RTS
8455 \
8460 .delay
8470 LDY #255
8480 .delayloop
8490 NOP
8500 DEY
8510 BNE delayloop
8520 RTS
8530 .text
8540 EQUS "P100_01.htm",0
PJ

Post Reply