MOS Technology 6522 Versatile Interface Adapter (VIA)

January 19, 2026 · View on GitHub

1. Overview

The MOS Technology 6522 VIA is a general-purpose I/O controller designed to interface the 6502 family of microprocessors with external peripherals. Introduced in the mid-1970s, it provides parallel I/O ports, timers, shift register support, and interrupt handling. The 6522 is widely used in systems such as the Commodore PET, VIC-20, Apple II, BBC Micro, and many 6502-based embedded designs.


2. General Characteristics

FeatureDescription
Data width8-bit
AddressingMemory-mapped I/O
Registers16 (4-bit register select)
I/O portsTwo 8-bit ports (Port A, Port B)
TimersTwo 16-bit timers
Shift register8-bit serial I/O
InterruptsMaskable, multiple sources
ClockSystem clock (φ2)

3. Pin Functions (Logical)

3.1 Port A (PA0-PA7)

  • 8-bit bidirectional parallel I/O
  • Handshake support via CA1 / CA2

3.2 Port B (PB0-PB7)

  • 8-bit bidirectional parallel I/O
  • Handshake support via CB1 / CB2
  • PB6 and PB7 may be controlled by Timer 1

3.3 Control Pins

PinDescription
CA1 / CB1Interrupt-capable control inputs
CA2 / CB2Handshake / pulse / interrupt pins
IRQInterrupt request output (active low)
RESETReset input

4. Register Map

Registers are selected using 4 address lines (RS0-RS3). The base address is system-defined.

OffsetRegisterDescription
$0ORBOutput Register B
$1ORA / IRBOutput Register A / Input Register B
$2DDRBData Direction Register B
$3DDRAData Direction Register A
$4T1C-LTimer 1 Counter Low
$5T1C-HTimer 1 Counter High
$6T1L-LTimer 1 Latch Low
$7T1L-HTimer 1 Latch High
$8T2C-LTimer 2 Counter Low
$9T2C-HTimer 2 Counter High
$ASRShift Register
$BACRAuxiliary Control Register
$CPCRPeripheral Control Register
$DIFRInterrupt Flag Register
$EIERInterrupt Enable Register
$FORA / IRAOutput Register A / Input Register A

5. Data Direction Registers (DDRA / DDRB)

Each bit controls the direction of its corresponding port pin:

  • 0 = Input
  • 1 = Output
DDRB bit = 1  PBx is output
DDRB bit = 0  PBx is input

6. Timers

6.1 Timer 1 (T1)

  • 16-bit down counter
  • Can operate in one-shot or free-running mode
  • Can toggle PB7 on timeout
  • Generates interrupts

6.2 Timer 2 (T2)

  • 16-bit down counter
  • Supports pulse counting on PB6
  • One-shot operation only

7. Shift Register (SR)

  • 8-bit shift register
  • Can shift data in or out
  • Clock source selectable via ACR
  • Often used for serial communication or keyboard scanning

8. Control Registers

8.1 Auxiliary Control Register (ACR)

BitFunction
7Timer 1 control (PB7 output)
6Timer 1 mode (free-run / one-shot)
5Timer 2 control
4Shift register mode
3Shift register clock source
2Port B latching
1Port A latching
0Unused

8.2 Peripheral Control Register (PCR)

Controls CA1, CA2, CB1, CB2 behavior:

  • Input/output mode
  • Active edge selection
  • Pulse or handshake modes

9. Interrupt System

9.1 Interrupt Flag Register (IFR)

BitSource
7IRQ status (any enabled interrupt)
6Timer 1
5Timer 2
4CB1
3CB2
2Shift Register
1CA1
0CA2

9.2 Interrupt Enable Register (IER)

  • Bit 7 determines set/clear mode:

    • 1 = set bits
    • 0 = clear bits
Write \$80 | mask  enable interrupts
Write \$00 | mask  disable interrupts

10. Reset Behavior

On RESET:

  • All DDR bits cleared (ports default to input)
  • Timers stopped
  • Shift register disabled
  • Interrupts disabled

11. Timing Notes

  • VIA registers are accessed synchronously with φ2
  • Timer counters decrement once per φ2 cycle
  • Some operations have side effects when reading/writing registers

12. Common Use Cases

  • Keyboard and joystick interfaces
  • Parallel printer interfaces
  • Timers and event counting
  • Simple serial communications
  • General-purpose GPIO expansion

ChipNotes
6522Original NMOS VIA
65C22CMOS VIA, faster, lower power
6520Earlier PIA (simpler)

14. References