Skip to content

MOS 6522 VIA

Ports, timers and interrupts around the processor

The Versatile Interface Adapter connects a processor to external devices through two programmable 8-bit ports. Timers, handshaking, a shift register and interrupt flags add jobs that raw input and output alone cannot do.

The MOS 6522 Versatile Interface Adapter, or VIA, gives a processor a way to deal with events outside its instruction stream. Two 8-bit ports connect to devices. Timers count without a software delay loop. Interrupt flags record work that needs attention. A shift register can transfer bits serially. The host processor configures those facilities through memory-mapped registers.

The BBC Micro makes its versatility particularly clear. It has two VIAs with different responsibilities. One serves system devices including the keyboard and sound controls; the other serves the printer and user port. The chip design is the same, but the wiring gives each instance a different job. (The Advanced User Guide, chapter 22.)

A port bit can face either way

Each port has a data-direction register. Individual bits can be inputs or outputs, so a program can read some lines while driving others. The value in an output register and the direction of the pin are separate settings. Writing a byte is not enough if the intended output lines remain configured as inputs.

Handshaking control lines help coordinate transfers with a peripheral. Their modes can detect or generate transitions, rather than leaving the CPU to guess when an external device has responded. Which mode is useful depends on the device connected to the pins. (MOS, peripheral ports and control lines.)

Let a timer do the waiting

Timer 1 has a 16-bit counter and reload latches. It can run for one interval or repeat, and a suitable mode can change the PB7 output when it expires. Timer 2 has different operating options, including counting external pulses. Two timer registers with similar names are therefore not interchangeable facilities.

The eight-bit shift register adds serial-to-parallel and parallel-to-serial operation. Clocking and control choices determine how it moves bits. It is one function among the VIA’s ports and timers, with shared pins and mode settings that software must coordinate.

An interrupt needs an explanation

Several internal events share one interrupt output. The interrupt flag register says which event occurred; the enable register says which sources are allowed to request service. A handler must identify and acknowledge the relevant cause according to that source’s rules. Returning from the CPU’s interrupt routine does not explain or clear the VIA event. (MOS, control of interrupts.)

The VIA complements a processor such as the 6502; it does not replace it. Nor does its name prescribe an address. A BBC program’s VIA addresses belong to the BBC’s decoding. Other computers—and later CMOS variants of the chip—need their own hardware documentation before register behaviour or electrical details are assumed to match.

Sources

  • MOS Technology, MCS6522 Versatile Interface Adapter, preliminary data sheet, November 1977. Preserved transcription and original scan archive.
  • Andrew Bray, Adrian Dickens and Mark Holmes, The Advanced User Guide for the BBC Microcomputer, Cambridge Microcomputer Centre, chapter 22: the two VIAs in an actual computer.

Checked. Verified against primary sources and signed off by a person.