PPI - Programmable Peripheral InterfaceThe 8255A programmable peripheral interface (PPI) implements a
general-purpose I/O interface to connect peripheral equipment to a
microcomputer system bus. The core's functional configuration is
programmed by the system software so that external logic is not required
to interface peripheral devices.
In the SVI-328/318 the 8255 is used to strobe the keyboard
lines, to interface joystick fire button switch, the paddle and to
control the cassette tape system. The following I/O ports are used to communicate with the PSG.
Programming the 8255The 8255 has 3 8-bit ports (A,B and C), each of which can have
a different I/O Status (i.e. input or output). Port C can also be
programmed to operate in two halves. (As two separate 4-bit ports). The
functional configuration of each port is programmed bu the system
software. In essence, the CPU "outputs" a control word to the 8255. The
control word contains information such as "mode", "bit set", "bit
reset", etc, that intializes the fuctional configuration of the 8255. Using the 8255 PortsWhen writing to a port: 8255 PPI Control ByteThis byte controls the Input/Output (I/O) status and operating
mode of each port. Configuration control byteWhen bit 7 is set to 1, the command byte operates in the following way: Bit 7: Control byte function (1=Configuration control byte) Bit 6: } Operating Mode (Port A and Port C upper) Bit 5: } Bit 4: Port A I/O Status (0: Output, 1: Input) Bit 3: Port C (upper) I/O Status (0: Output, 1: Input) Bit 2: Operating Mode selection (Port B and Port C lower) Bit 1: Port B I/O Status (0: Output, 1: Input) Bit 0: Port C (lower) I/O Status (0: Output, 1: Input) Port A and Port C (upper) Operating modeBit 6 Bit 5 Mode selection ---------------------------------------------- 0 0 Mode 0 0 1 Mode 1 1 0 Mode 2 1 1 Mode 2 Port B and Port C (lower) operating modeBit 2 Mode Selection ------------------------------ 0 Mode 0 1 Mode 1 Bit Set/Reset control byteWhen bit 7 is set to 0, the control byte operates in the following way: Bit 7: Control byte function (0=Bit Set/Reset control byte) Bit 6: } Not used. (send 0) Bit 5: } Bit 4: } Bit 3: } Bit to change. Bit 2: } Bit 1: } Bit 0: Bit operation 1: Set bit (make bit=1), 0: Reset bit (make bit=0) Table to show how bit to change is coded: Bit 3 Bit 2 Bit 1 Bit selected ------------------------------------------------------------ 0 0 0 Bit 0 0 0 1 Bit 1 0 1 0 Bit 2 0 1 1 Bit 3 1 0 0 Bit 4 1 0 1 Bit 5 1 1 0 Bit 6 1 1 1 Bit 7 Port Usage in SVI-318/328For each port, the port address (at which the port can be
accessed) it's normal I/O Status (unless changed by the user), it's
operating mode (unless changed by the user) are given. Port A (Port address: 98H) (I/O Status: Input) (Operating mode: 0)Bit 7: Cassette: Read data Bit 6: Cassette: Ready Bit 5: Joystick 2: Trigger Bit 4: Joystick 1: Trigger Bit 3: Joystick 2: EOC Bit 2: Joystick 2: /SENSE Bit 1: Joystick 1: EOC Bit 0: Joystick 1: /SENSE Port B (Port address: 99H) (I/O Status: Input) (Operating mode: 0)Bit 7: Keyboard: Column status of selected line Bit 6: Keyboard: Column status of selected line Bit 5: Keyboard: Column status of selected line Bit 4: Keyboard: Column status of selected line Bit 3: Keyboard: Column status of selected line Bit 2: Keyboard: Column status of selected line Bit 1: Keyboard: Column status of selected line Bit 0: Keyboard: Column status of selected line Port C (Port address: 97H) (I/O Status: Output) (Operating mode: 0)Bit 7: Keyboard: Click sound bit (pulse) Bit 6: Cassette: Audio out (pulse) Bit 5: Cassette: Write data Bit 4: Cassette: Motor relay control (0=on, 1=off) Bit 3: Keyboard: Line select 3 Bit 2: Keyboard: Line select 2 Bit 1: Keyboard: Line select 1 Bit 0: Keyboard: Line select 0 Control Port (Port adress: 96) (I/O Status: Output)(Operating mode: 0) Register read (Port adress: 9A) (I/O Status: Input)(Operating mode: 0) Programming ExamplesSetting up the 8255; Sample - Mode select and I/O setup of A,B,C ppi EQU 97H LD A,92H OUT (ppi), A ; Sample - Check if CTRL-STOP is pressed mode EQU $9A portC EQU $96 portB EQU $99 IN A,(mode) ; Read current PPI mode settings AND $F0 ; Set bit 15 OR $06 OUT (portC),A ; Write to PPI port C IN A,(portB) ; Read from PPI port B AND $22 ; Mask CTRL and STOP keys RET NZ ; Return, if not pressed ...
Source: Tomas Karlsson |
|||||||||||||||
|