RS232 and flow control

Basic and Machine Language

Moderator: Moderators

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

RS232 and flow control

Post by Bobbi »

I am playing with RS232 in preparation for my WiModem's arrival.

If I am correct in my reading of the VIC20 PRG, if I have a 'x-line handshake" interface (using CTS and DSR RS232 lines) then I should have proper incoming flow control. Characters are received and handled by the NMI handler and put in the 256 byte Rx buffer at the top of RAM. When the buffer is full the RS232 CSR should be cleared (or set, I forget ... Commodore has this inverted anyhow) and the other end should stop sending characters. Is this correct?

If this is correct, then I don't have to worry about dropping characters if I let the buffer fill up while doing something CPU intensive (parsing XML tags.)

When I try this in VICE with the user port serial emulation and executing and external netcat process, characters get dropped. However I suspect that the VICE only implements a '3-line' RS232 interfae without CTS/DSR. Anyone know if I am correct?
User avatar
srowe
Vic 20 Scientist
Posts: 1325
Joined: Mon Jun 16, 2014 3:19 pm

Re: RS232 and flow control

Post by srowe »

X-line handshaking is broken in the VIC KERNAL, the wrong VIA registers are read when it tries to read DSR and CTS. READST always returns 0 for the RS-232 channel too.
Bobbi
Vic 20 Afficionado
Posts: 355
Joined: Thu Oct 13, 2016 11:35 am
Location: Toronto
Occupation: Programmer

Re: RS232 and flow control

Post by Bobbi »

I saw a comment to the effect that the code looks at the incorrect VIA in the annotated kernal disassembly. Best place to look when trying to understand this stuff - neither the PRG nor 'VIC Revealed' is very clear.

I guess I have two options:

1) Do my own assembly routine for RS232. Presumably I can copy the broken kernal routine in my own code with suitable relocations and then fix the error where it references the wrong VIA. Then I can (hopefully) rely on the handshaking to prevent overruns. Someone must have done this before.

2) Or the other (lazy) alternative is just to never let the buffer fill up, I guess ... which means I need to copy either the raw XML or the processed output somewhere ... most likely disk / SD2IEC, unless I restrict myself to 20K or so of RAM buffer. Disc is fast enough at 400 bytes/sec or so (plenty good enough for 1200 baud ~ 120 bytes / sec). This has the attraction of being easy to do - I already have the RSS reader working from a disk file so I would basically only have to implement code to pull down the RSS feed XML URL and dump it to disk. Not too elegant (or fast) but it will get a working prototype fast.

I am trying to map out the proper architecture for my RSS reader app ... it would be great to be able to receive bytes and parse XML in parallel with displaying the formatted output on the screen. However since RS232 uses NMI it may get messy to do stuff in an IRQ routine.
Post Reply