Sinclair ZX Spectrum Service Manual
Spectrum For Everyone https://spectrumforeveryone.com/
17
1.8 RS232/MIDI INTERFACE
The RS232C/MIDI interface is implemented using the Port A Data Store in the sound generator chip IC32.
The data store is a special register at octal address 16 which accesses an 8-bit bi-directional port A7-A0.
The port occupies the same I/O space as the sound generator registers and is accessed in much the
same way. The addition of a read cycle at I/O address FFFD
H
allows the Z80 to input data.
The port direction is determined by a control bit written to register R7 on bus line D6. When D6 is low
the port is configured as an input and when high as an output. In this application A3-AO are only used as
outputs and A7-A4 as inputs. A3/A2 supply an RS232C driver IC33 which converts the TTL outputs to
RS232C levels (+12V); A2 and A3 drive the CTS and RXD interface lines respectively. A4-A7 are supplied
from an RS232C receiver IC34 which converts the RS232C inputs to TTL levels; A6 and A7 are driven by
the DTR and TXD interface lines respectively. The data register contents are summarised as follows:
It is evident from the signal directions that the Spectrum 128 adopts the role of a data communications
equipment (DCE). However, DTR and CTS do not perform a handshake but are the same signal
transmitted in opposite directions. The transmission format is asynchronous, full duplex with 11-bit data
frames comprising 1 start bit, eight data bits and two stop bits. Two stop bits are always sent, but the
interface can receive satisfactorily with one.
1.9 KEYPAD SCANNING
The keypad (Figure 1.7) comprises a 5 x 4 switch matrix and a peripheral interface controller (PIC) with
on-chip program and scratchpad memories. The PIC operates from a +5V rail derived by a simple
stabiliser from the + 12V Spectrum supply, and is clocked from an external LC network. The nominal
clock frequency is 2.556 MHz but may vary between 1.278 MHz and 3.835 MHz dependent on
component tolerances. The master clear input (MCLR) is active for a period after power-up or if the
+12V supply is temporarily disconnected.
A two-part protocol first synchronises the PIC with the Z80 after power up (or if the flex cable
connection is temporarily broken) and then supports the transfer of keystroke data. Assuming
synchronisation has been achieved (see below) the keypad scans the keypad once every other interrupt
on demand from the Z80.
The keypad scanning routine is much the same as the routine adopted by the Z80 and ULA when
scanning the main keyboard. The PIC addresses each column in turn and scans the rows to determine
whether a key is pressed. The results of the scan are logged and passed to the Z80 on a
demand/response basis (see para. 5.8.9). Each demand prompts the PIC to scan a row and report any
change in the status since the previous scan. If there is no change, the PIC responds negatively, sending