Micropower |
Volume 2 · Number 3 · July 1982 |
Page 24 of 37 |
---|
This routine, which handles all the serial output, is extremely simple, because all the data serialisation routines, including the addition of start and stop bits, and the data transmission, is performed by the UART chip. The contents of the accumulator are first saved on the stack; the accumulator is then output to port 1. An input/output operation is decoded on the Nascom 2 by a I/O PROM, IC26, which uses address lines A0, Al and A2, and buffered Read and Write lines RDB and WRB to select bytes of data stored in the PROM. This data then controls the keyboard and UART. When data is output to port 1 the ‘address’ used by the PROM is 00001001 (binary), selecting the 10th byte in the PROM, which has the value £EF. When this is placed on the PROM outputs, all the lines remain ‘high’ except D4, which is connected to the Transmitter Buffer Register Load line on the UART. Thus the data in the accumulator, which has been placed on the data bus by the Port Output instruction, is transferred to the UART transmitter. The UART then procedes to send out this data in serial form, adding the necessary start and stop bits.
Meanwhile, the Z80 processor has nothing much to do. It sits in a loop, reading data out from port 2 and testing bit 6. Decoded by the I/O PROM, the Port 2 read enables the UART status flags. Bit 6 of the data bus is connected to the line which signals that the transmitter buffer is empty. Thus bit 6 going low informs the processor that the data (including the stop bits) has been transmitted. The value initially in the accumulator is then recovered from the stack, and the routine terminated.
You will note that the data bus is connected to the UART input, output and status registers; which particular registers are used by any one operation is determined by the control bytes output by the I/O PROM.
This subroutine checks the serial input port to see if a character has been received. If no character is available it returns with the carry flag clear; otherwise, the carry flag is set and the character is loaded into the accumulator. Once again, the routine is very simple, because the processor merely gets the data from the UART, which has to do all the deserialisation. The first operation is to read port 2. As in the case of SRLX, this enables the UART status flags. Bit 7 of the data bus is connected to the Data Received line, which goes high when the UART has obtained a data byte. The byte read in from port 2 is rotated from the accumulator into the processor carry flag. Thus if no data has been received the carry flag is reset, and the routine ends. If the Data Received line is high, the carry flag will be set by the rotate, and the processor then reads port 1 into the accumulator. This read operation, decoded by the I/O PROM, pulls the UART Rece1ver
Page 24 of 37 |
---|