6520 PIA (Peripheral Interface Adapter)

Year
1979
Type
Component
Category
Support chip — parallel I/O, joysticks, SIO control, memory banking
Manufacturer
MOS Technology / Synertek / Motorola (parts made for Atari)
Rockwell R6520 PIA with Atari part number C014795-12

Overview

The fourth chip on the Atari's I/O block is not an Atari design at all. The PIA is a MOS Technology MCS6520A — a pin-for-pin, electrically identical replacement for Motorola's MC6820, whose principal designer was Bill Mensch — or an equivalent such as the Motorola MC6821. It gives the computer two 8-bit bidirectional ports (A and B), each bit individually set as input or output, plus four handshake/control lines.

Atari uses those resources for a grab-bag of jobs. Port A reads the four direction switches of joysticks 1 and 2. On the 400/800, port B does the same for joysticks 3 and 4. The XL/XE computers have only two joystick ports, so Atari repurposed port B — the register PORTB at $D301 — as the machine's memory-management control, switching the OS ROM, BASIC ROM, Self Test ROM and (on the 130XE) the extra RAM banks in and out. The control lines carry the SIO bus's command, motor, proceed and interrupt signals.

Specifications

Item Detail
Address range $D300–$D303 (PORTA, PORTB, PACTL, PBCTL), mirrored through $D3FF
Atari part numbers C012298 = Synertek P6520A (early 400/800); C014795 = any 2 MHz 6520 equivalent; C014812 = 68B21 (2 MHz MC6821) or equivalent
Port A Joystick 1–2 directions; also paddle triggers, trackball, touch-tablet buttons, light-pen button, XEP80 data
Port B 400/800: joysticks 3–4. XL/XE: memory control (PORTB)
CA2 / CB2 SIO motor control (cassette) / SIO command line
CA1 / CB1 SIO proceed / SIO interrupt (rarely used — the 1030 modem is a notable exception)

PORTB on XL/XE machines

Bit Function
0 1 = OS ROM at $C000–$FFFF, 0 = RAM
1 0 = BASIC ROM at $A000–$BFFF, 1 = RAM (no effect on the 1200XL)
2–3 130XE: select extended bank 0–3
4 130XE: CPU sees extended bank at $4000–$7FFF when 0
5 130XE: ANTIC sees extended bank when 0
6 XE Game System: 0 = Missile Command ROM enabled
7 0 = Self Test ROM mapped at $5000–$57FF

On the 1200XL, which has neither BASIC nor extra RAM, port B also handles LED control for its two indicator lights. Pull-up resistors hold bits 0 and 7 (and bit 1 except on the 1200XL) high when the PIA resets to input mode, which guarantees the OS ROM is on and BASIC/Self Test are off after a reset.

Using it today / tips

  • Clearing bit 0 is how software gets the "RAM under the OS". Interrupts must be handled carefully while the OS ROM is switched out — a classic cause of lockups.
  • Why some 400/800 games crash on an XL. Games that initialise the PIA for four joysticks can clear PORTB bit 0, switching off the OS ROM under their own feet; Atari's Translator disk cannot fix this because it is a hardware difference.
  • Floating bits. On stock XL/XE machines the unused PORTB bits are not tied high or low, so they can drift when set as inputs (bits 2–6 on the 600XL/800XL/65XE, bit 6 on the 130XE, bits 1–6 on the 1200XL). Memory-detection routines should not trust them.
  • Expansion RAM. Most third-party XL/XE memory upgrades extend the 130XE scheme by using more PORTB bits, which is why "130XE-compatible" is the common denominator.
  • Reset. On XL/XE the RESET key resets the PIA (clearing all registers); on the 800 it is reset only at power-on.

Credits