cc65 and RS232 User Port Serial

Basic and Machine Language

Moderator: Moderators

Bobbi
Vic 20 Afficionado
Posts: 350
Joined: Thu Oct 13, 2016 11:35 am
Location: Toronto
Occupation: Programmer

Re: cc65 and RS232 User Port Serial

Postby Bobbi » Sun Feb 26, 2017 4:53 pm

I have had the opportunity to do a pile more testing. RS-232 seems very solid now at 1200 baud using v3 of srowe's wedge! Excellent work!!

On a related question, does anyone know a way to write to a disk file via the IEC serial port while also downloading data from user port RS-232? The kernal routines interact with one another with the result that the data obtained from RS232 is completely garbled. How do terminal programs get around this for XModem downloads for example, or just logging of the session to disk file? I need a way to do this for another project I am working on.

User avatar
Mike
Herr VC
Posts: 3103
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: cc65 and RS232 User Port Serial

Postby Mike » Tue Jan 09, 2018 3:34 am

srowe wrote:Here's v3 of the wedge. The ISR now disables all further interrupts and processes all pending ones before re-enabling. This should cope with any combination of Tx and Rx states, as well as you pounding on the RESTORE key.

I've run it for a while receiving data at 1200 baud, I've not seen a dropped or corrupt character.

I have another question:

As stated in Denial Wiki, hardware handshake is broken with the original RS232 routines in the KERNAL. Does your wedge fix this issue?

User avatar
srowe
Vic 20 Nerd
Posts: 518
Joined: Mon Jun 16, 2014 3:19 pm

Re: cc65 and RS232 User Port Serial

Postby srowe » Tue Jan 09, 2018 12:45 pm

Mike wrote:As stated in Denial Wiki, hardware handshake is broken with the original RS232 routines in the KERNAL. Does your wedge fix this issue?


Short answer, yes. Long answer: sort of.

Yes, the wedge reads from the correct VIA registers. However the behaviour implemented is still the original use of RTS and CTS for use with half-duplex modems, this is not the same as the current usage of those lines for flow control. See https://en.wikipedia.org/wiki/RS-232#RTS,_CTS,_and_RTR
It is not possible to fix READST in the wedge as the routine is not vectored. There is a routine in the code, RSREADST, that correctly implements it.

User avatar
Mike
Herr VC
Posts: 3103
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: cc65 and RS232 User Port Serial

Postby Mike » Tue Jan 09, 2018 4:03 pm

srowe wrote:Short answer, yes. Long answer: sort of.

Thank you!

The reason I've been asking is a WIP, that in one of its implementations would sport two VIC-20s connected with a nullmodem cable.

So it's sensible for me to make a fully wired nullmodem cable (not just 3-wire, i.e. RxD <-> TxD vs GND, and RTS/CTS bridged in the connector), in fact: both sides would have the same understanding how the hardware handshake is supposed to work. :)

Cheers,

Michael

User avatar
srowe
Vic 20 Nerd
Posts: 518
Joined: Mon Jun 16, 2014 3:19 pm

Re: cc65 and RS232 User Port Serial

Postby srowe » Wed Jan 10, 2018 2:22 am

No, the original definition of CTS/RTS is not symmetrical. The VIC routines are coded as a DTE device, from what I can determine the flow is as follows for a full-duplex session:

  • When the RS-232 device is open DTR and RTS are set high, if the DSR line is low an error is flagged
  • If during Tx the DSR or CTS line goes low an error is flagged
  • When the device is closed DTR and RTS are set high again

A half-duplex session is more complex:

  • When a channel is opened for output the DSR is checked and if low an error is flagged
  • - if RTS is low it is because an input channel was opened (see below), loop while CTS is high then raise RTS
  • When a channel is opened for input the DSR is checked and if low an error is flagged
  • - if RTS is high then loop while timer T1 is running then lower RTS

For added confusion all the control lines (both in and out) go through an extra inverter on the VIC-1011A board.

User avatar
Mike
Herr VC
Posts: 3103
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: cc65 and RS232 User Port Serial

Postby Mike » Wed Jan 10, 2018 2:34 pm

O.K., then I'll have to look deeper into it. The goal for me remains to directly couple two VIC-20s over the user port RS232, without any level shifting - and preferably without any signal inversion necessary. And, if possible, with functioning hardware handshake.

Think of a 'talk' application with two terminals, except one of the two terminals is supposed to do something else. :wink:

srowe wrote:The VIC routines are coded as a DTE device

That should be perfectly in line with my plans. A nullmodem cable actually lets a DTE device appear as DCE device for the DTE device on the other side (and vice versa): https://en.wikipedia.org/wiki/Null_modem

User avatar
srowe
Vic 20 Nerd
Posts: 518
Joined: Mon Jun 16, 2014 3:19 pm

Re: cc65 and RS232 User Port Serial

Postby srowe » Wed Jan 10, 2018 2:45 pm

I can look into changing the wedge to use the modern form of RTS/CTS handshaking. It should be just a matter of checking in the Tx interrupt routine before scheduling a new byte and having some form of watermark in the Rx routine.

User avatar
srowe
Vic 20 Nerd
Posts: 518
Joined: Mon Jun 16, 2014 3:19 pm

Re: cc65 and RS232 User Port Serial

Postby srowe » Thu Jan 11, 2018 3:53 am

Mike wrote:That should be perfectly in line with my plans. A nullmodem cable actually lets a DTE device appear as DCE device for the DTE device on the other side (and vice versa)


That only works when the protocol is symmetric.

User avatar
srowe
Vic 20 Nerd
Posts: 518
Joined: Mon Jun 16, 2014 3:19 pm

Re: cc65 and RS232 User Port Serial

Postby srowe » Sat Jan 27, 2018 8:10 am

I am working on this when I have time. I've decided to rip out support for 2 stop bits, parity checking and anything other than 8 bits. This reduces the number of cycles spent in an interrupt and may mean it can support higher baud rates.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest