Micro­power

  

Volume 1, Number 1 – August 1981








Page 12 of 33











PRINTERFACE
THE EPSON MX-80 F/T

by P. Whittaker

The Epson MX-80 is a nine-wire dot matrix printer which as supplied has a standard Centronics 8 bit parallel interface. This can be connected directly to a Nascom PIO, so all that you need to run the printer is the software to interface it to the output ports. The first requirement is an initialisation routine to set the eight bits of one port to output lines, for transfer of data to the printer, and to configure the other port for control of the transfer. The simplest way to synchronise the machines only needs the ‘busy’ line from the printer, which is low whenever the printer is able to receive data, and a strobe signal from the computer, which is taken low to tell the printer that data is to be read in.

In the standard Nascom port A of the PIO is addressed as port 4, and the control port which specifies its configuration is port 6; similarly, data for port B is output to port 5, and control words to port 7. A suitable PIO initialisation routine is thus:–

LD A, £CFControl word to specify mode 3
OUT (6) , ASend this to port 6
XOR ANext byte sent to port 6 specifies which
OUT (6), Alines are outputs (0), which inputs (1)
LD A, £CFNow set port B to mode 3
OUT (7), A
LD A, 1Use bit 0 as input (for ‘busy’ line)
OUT (7), A
LD A, 2Set strobe line high
OUT (5), A

If you are using Nas-sys, the initialisation routine should end by storing the address of the printer output program at £0C78, so that when the user I/O is activated with command U output will be routed to the printer. With the earlier monitors the corresponding address is £C4B, but the output program will have to call the CRT routine. After a reset the output address will have to be reinserted, but the PIO will not need to be initialised again.

The output routine has to test the ‘busy’ line before sending a character to the printer; as soon as this line is low, the character is output at port A and the strobe line is pulled to zero volts.

PUSH AFSave the character to be printed
TSTOIN A, (5)Read port B
RRC ARotate bit 0 to carry flag
JR C, TSTOLoop while bit 0 is high
POP AFRecover character
PUSH AFResave
OUT (4), AOutput to printer
XOR AStrobe signal to printer
OUT (5), A
LD A, 2Reset strobe high
OUT (5), A
POP AFRecover character
RETEnd of routine








Page 12 of 33