Before you actually build anything using this guide, please read the disclaimer.

Output - The Printer Port

Printer port pin diagram
Printer port pinout (as viewed from the rear of the computer)
PinSignalPinSignal
1STROBE*16GND
2D019GND
3D120GND
4D221GND
5D322GND
6D423GND
7D524GND
8D625GND
9GND26GND
11BUSY28GND
14GND33GND

All pin numbers not listed in the table on the left are NOT CONNECTED. Strobe is active low.

A note on printer cables and strange pinouts: Astute readers will have noticed the lack of a pin 18 or a pin 36. This was intentional in Amstrad's design of the CPC. A standard Centronics printer connector has 36 pins. However, a standard-sized edge connector has 34 tracks. Amstrad's compromise was simply to not connect pins 18 and 36 to the computer.

This means that when connecting a printer to the CPC, every wire connects between the SAME NUMBERED track of the computer's edge connector as the pin of the socket on the printer. Pins 19 and 36 from the printer, however, should not be connected to the computer.

Also bear in mind that the CPC's printer port is only 7 bits wide. When you send a byte to the port, the highest bit is ignored. However, see below for a way of using the strobe line as an additional output.



Sending data to the printer port

From BASIC

You can send any 7-bit binary value (i.e. 0 to 127 in decimal) to the 7 data lines (D0 to D6) of the printer port simply by using

PRINT #8,CHR$(n)

where n is your 7-bit number.

However, there is another way. Should you require an eighth output, you can use

OUT &EF00,n

where n is an 8-bit number (i.e. 0 to 255). This method uses the strobe line (pin 1) as the eighth output.


In Machine Code

Virtually the same as in BASIC. Just OUT the value to &EF00. There is one point worth noting, and that is that the printer port is wired so that the low byte of the port address doesn't matter. So if you wanted to send &3F to the printer port, you don't need to do:


LD A,&3F
LD BC,&EF00
OUT (C),A
Instead, just do:

LD BC,&EF3F
OUT (C),C

This is very easy and there is not really all that much reason to use the firmware calls for printing. Unless maybe you're using the BUSY line on pin 11 for something. Anyway, just in case you need 'em for something, here they are.


MC PRINT CHAR: CALL &BD2B

Entry conditions:

A contains the character to send (highest bit ignored)

Exit conditions:
Carry true if the character was sent OK.
Carry false if the printer timed out.

A and other flags corrupt. All other registers preserved.

Notes:

In V1.1 firmware, the character to be sent is translated using the printer translation table as set by MC PRINT TRANSLATION (jumpblock entry at &BD58, routine not available on V1.0 firmware). If the supplied character is not found in the table then it is sent as supplied without translation. However, if the character is found in the translation table then the corresponding translation is sent instead; unless the translation is &FF in which case the character is ignored and nothing is sent.

This routine calls the Machine Pack indirection MC WAIT PRINTER (&BDF1) to send the character. The default indirection routine waits for the Centronics port to become non-busy then sends the character. If the port remains busy for too long (approx. 0.4 seconds) then the routine times out and no character is sent. This time out is provided so that the caller can test for break whilst driving the printer.


MC BUSY PRINTER: CALL &BD2E

Entry conditions:

None.

Exit conditions:
Carry true if the Centronics port was busy.
Carry false if the Centronics port wasn't busy.

Other flags corrupt. All other registers preserved.


MC SEND PRINTER: CALL &BD31

Entry conditions:

A contains the character to send (highest bit ignored)

Exit conditions:

Carry true.

A and other flags corrupt. All other registers preserved.

Notes:

The printer must not be busy when a character is sent. Unlike MC PRINT CHAR, this routine will not wait for the printer to become non-busy.


So what can I do with these outputs?

The Centronics port outputs can be used with any TTL-compatible microchips. This includes the widely-available 74 series logic chips.

You could use the outputs to drive relays, which you could then use to switch virtually any electronic device on or off. However, activating relays may well require an additional power supply.


Further notes on the printer port

The port is properly referred to as the Centronics port latch. The "latch" bit simply means that once the state of the outputs has been set by sending a number to the port, the outputs will stay in that state until another value is sent.

On power up and other system resets the outputs of the Centronics port latch are cleared.


Back to: