I am trying to understand the riddle of how to receive data over RS-232 and write it to a diskette (SD2IEC) file.
I have already established that if I do a naive read-a-byte write-a-byte loop, then the data obtained from RS-232 is corrupted.
My next attempt is to read from RS-232 into a buffer. When the buffer is full, I drop RTS so the modem stops sending me data, spin for a bit to allow things to settle down, then write the buffer to disk (with cc65 cbm_write()). After a suitable delay, I raise RTS and the modem continues sending me data and I start filling up the next buffer.
It *almost* works. When I look at the file, the data is good except there are garbage characters which are aligned more-or-less with the block boundaries. Often there are four bad characters in a row at the block boundary. It seems that the disk write operation is trashing something RS-232 needs, but somehow it recovers after a while. My application keeps the RS-232 RX buffer basically empty at all times.
On VIC-20 RS-232 uses VIA1 and serial IEC uses VIA2 so I am not sure where the interaction is.
I am hoping that if I just preserve a couple of VIA registers or zero-page variables across the call to cbm_write() I should be able to make this work.
Basic and Machine Language
1 post • Page 1 of 1
Who is online
Users browsing this forum: Bing [Bot] and 1 guest