cbmeeks wrote:
However, shortly after that, it would send HELLO W" or "HELLO WORL". Sometimes it would chop off a few characters and replace with garbage. So, I realize what I did wasn't a proper driver. I had the speed set to 19200 so that may be way too fast for BASIC.
The TIA-232 speed affects the bit rate per datum sent or received on the (serial) wire, and has no direct relationship to how often you can process a datum. If you only write one datum per second it will still be serialized and transmitted at the rate of 19,200 bits per second, which is an interval of approximately 52 microseconds per bit. Assuming 8-N-1 format, 19.2Kbps is effectively 1920 bytes per second, amounting to approximately 521 microseconds per byte sent.
Where the data rate does become a factor is when the particular UART being used has no receiver (RxD) or transmitter (TxD) buffering, which is the case with the 65C51. In this case, you must immediately read RxD when the UART indicates a datum is present, and of course, you cannot write a datum to TxD until the UART indicates that it can accept it. Failure to immediately read RxD when a datum has been de-serialized will result in its loss should another datum arrive before the present one is read—an overrun error.
In the case of transmission, writing to TxD before the UART can serialize and send the datum will result in corruption or loss. All UARTs indicate to the microprocessor in some way when they can accept a datum for transmission. Unfortunately, that function is broken in the WDC 65C51. Hence a timing kludge has to be introduced to pace writes to TxD at a rate that is somewhat slower than the theoretical maximum for the serial data rate being used. Although BASIC's POKE statement is relatively slow-executing, it is likely the Apple II can write to the 65C51 faster than the latter can serialize and transmit, even at 19.2Kbps, which would explain the dropped characters.
This interesting experiment of yours is yet another case of highlighting the primitive and outdated nature of the 65C51. The 65C51's ancestry is that of the NMOS 6551 developed in the mid-1970s at a time when chip manufacturing was very limited compared to today. Much better UARTs exist—even the contemporaneous Motorola 6850 is a better device, and that's not saying much. Since those days, UARTs have incorporated much faster bus interfaces, have acquired features to reduce the likelihood of overrun and framing errors, don't demand as much processing as the old units to generate data flow, are much more adaptable to different applications, and support very high data rates. While I like working with the relatively ancient technology of the 65C02 and 65C816 (which is not to say that x86 technology is any less ancient—it's traceable in some ways to the Intel 8080), my interest doesn't extend to hobbling the system with antiquated and bug-prone I/O hardware.
Slightly OT, but not too much, is something I've been intermittently working on, which is a white paper on how to adapt NXP's 28L92 dual UART to a 65C02 or 65C816 system, the 28L92 being what I use in POC V1. It supports standard serial speeds up to 230.4Kbps, non-standard speeds up to 921.6Kbps, has 16-deep FIFOs (a big help in reducing the volume of IRQs), full CTS/RTS handshaking, programmable I/O pins, and a precision counter/timer, the latter which is the time base for POC V1 vi a 100 Hz jiffy IRQ. The 28L92 can be used with either 3.3 or 5 volt systems, with no loss of performance on 3.3 volts. My paper will include example interrupt-driven driver code that has been derived from what I have running on POC V1 and in use on Lordbubsy's MARC2 65C816 computer, which has a 26C92, the 8-deep FIFO predecessor of the 28L92.
NXP also makes a single channel version of the 28L92 called the 28L91, which is also adaptable to the 65C02 and 65C816. The 28L91 is functionally identical to the 28L92, except for having only one serial channel. My white paper will cover its use as well, in case anyone is interested.
Attachment:
File comment: NXP 28L91 UART
28L91_uart.pdf [268.4 KiB]
Downloaded 113 times
Attachment:
File comment: NXP 28L92 Dual UART
28L92_uart_dual.pdf [336.96 KiB]
Downloaded 98 times
—————————————————
EDIT: Attached data sheets.
—————————————————