As well as controlling three sound channels the 8910 PSG contains two eight bit data ports, called A and B, through which it interfaces the joysticks and the cassette input. The PSG appears to the Z80 as three I/O ports called the Address Port, the Data Write Port and the Data Read Port.

Address Port (I/O port A0H)

    The PSG contains sixteen internal registers which completely define its operation. A specific register is selected by writing its number, from 0 to 15, to this port. Once selected, repeated accesses to that register may be made via the two data ports.

Data Write Port (I/O port A1H)

    This port is used to write to any register once it has been selected by the Address Port.

Data Read Port (I/O port A2H)

    This port is used to read any register once it has been selected by the Address Port.

PSG Registers

    The following table summarizes all PSG registers:

Register Bits
R0Channel A Periodpa7pa6pa5pa4pa3pa2pa1pa0
R2Channel B Periodpb7pb6pb5pb4pb3pb2pb1pb0
R4Channel C Periodpc7pc6pc5pc4pc3pc2pc1pc0
R6Noise Tone---n4n3n2n1n0
R7/EnablePort B Dir.Port A Dir.C NoiseB NoiseA NoiseC ToneB ToneA Tone
R8Channel A Volume---A Modeva3va2va1va0
R9Channel B Volume---B Modevb3vb2vb1vb0
R10Channel C Volume---C Modevc3vc2vc1vc0
R11Envelope Periodep7ep6ep5ep4ep3ep2ep1ep0
R13Envelope Wave Shape----es3es2es1es0
R14I/O Port ACas
R15I/O Port BKana

Important note: the PSG registers R14 and R15 can be programmed for input or output. On MSX, R14 must be ever programmed for input and, R15, for output. Thus, bit 6 of R7 must ever be set to "0" (input) and, bit 7, to "1" (output). Programming them otherwise may cause severe damage to the machine, putting active coupling circuitry connected to R14 and R15 in short-circuit. More details on PSG register 7 section.

PSG Registers 0 and 1

    These two registers are used to define the frequency of the Tone Generator for Channel A. Variable frequencies are produced by dividing a fixed master frequency with the number held in Registers 0 and 1, this number can be in the range 1 to 4095. Register 0 holds the least significant eight bits and Register 1 the most significant four. The PSG divides an external 1.7897725 MHz frequency by sixteen to produce a Tone Generator master frequency of 111,861 Hz. The output of the Tone Generator can therefore range from 111,861 Hz (divide by 1) down to 27.3 Hz (divide by 4095). As an example to produce a middle "A" (440 Hz) the divider value in Registers 0 and 1 would be 254.

PSG Registers 2 and 3

    These two registers control the Channel B Tone Generator as for Channel A.

PSG Registers 4 and 5

    These two registers control the Channel C Tone Generator as for Channel A.

PSG Register 6

    In addition to three square wave Tone Generators the PSG contains a single Noise Generator. The fundamental frequency of the noise source can be controlled in a similar fashion to the Tone Generators. The five least significant bits of Register 6 hold a divider value from 1 to 31. The Noise Generator master frequency is 111,861Hz as before, used on a Linear Feedback Shift Register (LFSR) with the equation:

PSG Register 7

    This register enables or disables the Tone Generator and Noise Generator for each of the three channels. Notice that it uses inverse logic, that is, 0=Enable and 1=Disable. Also notice that PSG has three different tone generators, each attached to its corresponding channel, but only one noise generator, attached to the three channels at the same time.

    It also controls the direction of interface ports A and B, to which the joysticks and cassette are attached: 0=Input, 1=Output. Register 7 must always contain 10xxxxxx or possible damage could result to the PSG, there are active devices connected to its I/O pins. The BASIC "SOUND" statement will force these bits to the correct value for Register 7 but there is no protection at the machine code level.

PSG Register 8

Figure 28.

    The four Amplitude bits determine the amplitude of Channel A from a minimum of 0 to a maximum of 15. The Mode bit selects either fixed or modulated amplitude: 0=Fixed, 1=Modulated. When modulated amplitude is selected the fixed amplitude value is ignored and the channel is modulated by the output from the Envelope Generator.

PSG Register 9

    This register controls the amplitude of Channel B as for Channel A.

PSG Register 10

    This register controls the amplitude of Channel C as for Channel A.

PSG Registers 11 and 12

Figure 29.

    These two registers control the frequency of the single Envelope Generator used for amplitude modulation. As for the Tone Generators this frequency is determined by placing a divider count in the registers. The divider value may range from 1 to 65535 with Register 11 holding the least significant eight bits and Register 12 the most significant. The master frequency for the Envelope Generator is 6991 Hz so the envelope frequency may range from 6991 Hz (divide by 1) to 0.11 Hz (divide by 65535).

PSG Register 13

Figure 30.

    The four Envelope Shape bits determine the shape of the amplitude modulation envelope produced by the Envelope Generator:

Figure 31.

PSG Register 14

Figure 32.

    This register is used to read in PSG Port A. The six joystick bits reflect the state of the four direction switches and two trigger buttons on a joystick: 0=Pressed, 1=Not pressed. Alternatively up to six Paddles may be connected instead of one joystick. Although most MSX machines have two 9 pin joystick connectors only one can be read at a time. The one to be selected for reading is determined by the Joystick Select bit in PSG Register 15.

    The Keyboard Mode bit is unused on UK machines. On Japanese machines it is tied to a jumper link to determine the keyboard's character set.

    The Cassette Input is used to read the signal from the cassette EAR output. This is passed through a comparator to clean the edges and to convert to digital levels but is otherwise unprocessed.

PSG Register 15

Figure 33.

    This register is used to output to PSG Port B. The four least significant bits are connected via TTL open-collector buffers to pins 6 and 7 of each joystick connector. They are normally set to a 1, when a paddle or joystick is connected, so that the pins can function as inputs. When a touchpad is connected they are used as handshaking outputs.

    The two Pulse bits are used to generate a short positive- going pulse to any paddles attached to joystick connectors 1 or 2. Each paddle contains a monostable timer with a variable resistor controlling its pulse length. Once the timer is triggered the position of the variable resistor can be determined by counting until the monostable times out.

    The Joystick Select bit determines which joystick connector is connected to PSG Port A for input: 0=Connector 1, 1=Connector 2.

    The Kana LED output is unused on UK machines. On Japanese machines it is used to drive a keyboard mode indicator.

Go to next chapter: B.I.O.S.