Before you actually build anything using this guide, please read the disclaimer.
Printer port pinout (as viewed from the rear of the computer) |
Pin | Signal | Pin | Signal |
---|---|---|---|
1 | STROBE* | 16 | GND |
2 | D0 | 19 | GND |
3 | D1 | 20 | GND |
4 | D2 | 21 | GND |
5 | D3 | 22 | GND |
6 | D4 | 23 | GND |
7 | D5 | 24 | GND |
8 | D6 | 25 | GND |
9 | GND | 26 | GND |
11 | BUSY | 28 | GND |
14 | GND | 33 | GND |
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.
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.
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),AInstead, 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.
A contains the character to send (highest bit ignored)
A and other flags corrupt. All other registers preserved.
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.
None.
Other flags corrupt. All other registers preserved.
A contains the character to send (highest bit ignored)
Carry true.
A and other flags corrupt. All other registers preserved.
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.
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.
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: