C64 RS232 KERNAL routine: Abort on CLOSE?

From: Spiro Trikaliotis (ml-cbmhackers_at_trikaliotis.net)
Date: 2008-12-20 17:19:13

Hello,

inspired by a call for help in a posting on the German Forum-64
(http://www.forum64.de/wbb3/index.php?page=Thread&postID=285473#post285473),
I had a look into the RS232 routines of the C64, as I wanted to help the
person there.

Short: He opened the RS232 channel, send a byte, and immediately closed
it again. It worked in BASIC, but in Assembler, no character appeared.

I tracked it down to something which I (I am "strik" in that forum)
believe is a bug in the KERNAL:

If I close the RS232 channel, all transmissions are stopped immediately.
Even if some bits were already sent, the transmission is aborted.

Is this already known? For me, this is surprising. On the other side, I
must admit that I never used RS232 before, so I do not have experience
here.

Thus, my "fix" is to provide an additonal wait before closing the
channel, and it worked.

I also added a loop:

WaitForLastChar
        lda $029d
        cmp $029e
        bne WaitForLastChar

before closing. This loop is meant to make sure all characters from the
buffer have been put into the "virtual 6551". But I am not totally sure
how to determine that this last character has been completely sent. I
tried in the VICE monitor, looking into the are $029x, but before and
after the sending, I could not find any relevent difference.

Does anyone know what I am missing? What do I have to test?

Currently, I did a work-around by waiting approx. 50 ms before closing
the RS232 channel, which should suffice even for 10 bps transmissions,
if I calculated correctly.

Regards,
Spiro.

-- 
Spiro R. Trikaliotis                              http://opencbm.sf.net/
http://www.trikaliotis.net/                     http://www.viceteam.org/

       Message was sent through the cbm-hackers mailing list

Archive generated by hypermail pre-2.1.8.