Fact-checked by Grok 2 weeks ago

MOS Technology 6522

The MOS Technology 6522, commonly known as the , is an 8-bit developed for input/output interfacing in systems compatible with the 6502 family. It provides two bidirectional 8-bit ports (Port A and Port B), each with programmable data direction registers and associated control lines for synchronized data transfers. Additional features include two independent 16-bit interval timers (one configurable as an event counter), an 8-bit for asynchronous serial I/O, and an generation system to signal the processor of peripheral events. Operating on a single +5V supply with TTL-compatible I/O pins, the chip was fabricated using N-channel depletion-load technology and introduced in preliminary form in November 1977. The 6522 was a key support component in the MOS Technology 65xx ecosystem, enhancing the basic parallel interface adapter (6520 PIA) with timing and serial capabilities to enable more complex peripheral control in resource-constrained systems. It found widespread adoption in early personal computers and embedded applications during the late 1970s and 1980s, including the Commodore KIM-1 single-board computer for user I/O ports, the series for cassette and user port interfacing, and the for general peripheral management. In disk drive systems, such as the , it handled serial bus communications and timing, though early implementations sometimes required software workarounds due to hardware limitations like bugs. The chip's versatility also extended to non-Commodore platforms, supporting , printer, and interfaces in 6502-based designs from manufacturers like , which produced compatible versions. Over time, the 6522 influenced subsequent I/O chips, such as the MOS 6526 Complex Interface Adapter (CIA) used in the Commodore 64, which addressed some of its shortcomings while maintaining compatibility. Modern reproductions and variants, like the W65C22, continue to be available for retro computing and hobbyist projects, preserving its role in emulating classic 8-bit systems.

History and Development

Introduction

The 6522 played a pivotal role in 1970s and 1980s computing by providing essential I/O functionality in numerous 6502-based systems, including the Commodore VIC-20 and , , , video game console, and the digital dashboard of the 1984–1989 . It was second-sourced by manufacturers including Rockwell (as the R6522) and Synertek to meet demand in microprocessor-based designs.

Design Origins and Release

The MOS Technology 6522 Versatile Interface Adapter (VIA) was developed in the mid-1970s as an enhancement to the company's 6520 Peripheral Interface Adapter (PIA), which provided basic parallel I/O capabilities similar to the MC6820 but optimized for the 6502 ecosystem. The 6522 extended this foundation by incorporating two independent 16-bit interval timers and an 8-bit parallel-to-serial , enabling more versatile peripheral control, timing functions, and serial data handling in cost-sensitive microcomputer designs. MOS Technology was acquired by in 1976, during the chip's development phase. Building on the company's growing expertise in NMOS fabrication from the 6502 CPU (introduced in 1975) and the 6520 , the 6522 was engineered to support comprehensive interfacing needs for emerging home and hobbyist systems, such as input, printer , and serial communications, all within a single chip to minimize system complexity and cost. A preliminary for the device was issued in November 1977, marking its initial technical disclosure. The chip entered full production in , manufactured using an N-channel depletion-load NMOS process on a single +5V supply, housed in a 40-pin (DIP) for compatibility and ease of integration. To ensure broader availability amid MOS Technology's rapid expansion alongside the 6502 , the design was second-sourced by as the R6522 and by Synertek as the SY6522. Its low unit cost in volume, along with inclusion in MOS reference designs, drove early adoption in systems like the , facilitating the growth of affordable 6502-based microcomputers.

Architecture and Interfaces

Register Map

The MOS Technology 6522 Versatile Interface Adapter (VIA) organizes its internal functions into 16 consecutive 8-bit memory-mapped registers, selected using a driven by lines RS0–RS3. These registers are accessed relative to a base address determined by the inputs CS1 (active high) and CS2 (active low), with the device responding when CS1 is high, CS2 is low, and the R/¯W line specifies the operation, all synchronized to the falling edge of the φ2 clock. Register access follows specific protocols: writes latch data from the system data bus into the selected on the falling edge of φ2, while reads transfer the contents to the data bus valid on the rising edge of φ2; for example, writing to data direction configures port I/O immediately, and reading the does not clear flags unless explicitly written to. Certain exhibit dual functions, such as counters that preload from on , and flags that clear only when a '1' is written to the corresponding bit. The base address allows integration into systems like the 6502 bus, typically occupying 16 bytes in space. Note that the final production 6522 map differs from the November 1977 preliminary , which had an alternate arrangement of and shift . The following table summarizes the register map, with hexadecimal offsets from the base address:
OffsetRegister NameFunction Description
$00Port B Data (ORB/IRB)8-bit bidirectional I/O for Port B; write sets output levels, read returns input or latched output.
$01Port A Data (ORA/IRA)8-bit bidirectional I/O for Port A; similar to Port B, with handshake integration via CA1/CA2.
$02Port B Data Direction (DDRB)Write-only; configures each Port B bit as input (0) or output (1).
$03Port A Data Direction (DDRA)Write-only; configures each Port A bit as input (0) or output (1).
$04Timer 1 Counter Low (T1C-L)Read returns low byte of Timer 1 counter (clears interrupt flag); write loads low latch.
$05Timer 1 Counter High (T1C-H)Read/write accesses high byte of Timer 1 counter; writing starts countdown and clears flag.
$06Timer 1 Latch Low (T1L-L)Read/write low byte of Timer 1 preload latch.
$07Timer 1 Latch High (T1L-H)Read/write high byte of Timer 1 preload latch; writing to high initiates transfer to counter.
$08Timer 2 Counter Low (T2C-L)Read returns low byte of Timer 2 (clears flag); write loads low latch.
$09Timer 2 Counter High (T2C-H)Read/write high byte of Timer 2; writing starts operation and clears flag.
$0AShift Register (SR)8-bit serial/parallel data buffer; read/write transfers data for shifting.
$0BAuxiliary Control Register (ACR)Configures operational modes for timers and shift register.
$0CPeripheral Control Register (PCR)Sets input/output modes for peripheral control lines CA1/CA2/CB1/CB2.
$0DInterrupt Flag Register (IFR)Read shows pending interrupts; write '1' to bits to clear specific flags.
$0EInterrupt Enable Register (IER)Enables/disables interrupt sources; bit 7 sets/clears all enables.
$0FPort A Data No Handshake (ORA/IRA no CA2)Accesses Port A without affecting CA2 control lines.
Key registers feature bit-level controls for fine-grained configuration. The Auxiliary Control Register (ACR) at offset $0B uses bit 7 (SR) to select shift register interrupt control, bits 6–5 for 1 output functions (e.g., 00 for disabled, 11 for pulse), bits 4–3 for 2 output (similar options), bits 2–0 for transfer modes (e.g., 000 for free-run under system clock, 100 for T2 underflow gated). The Peripheral Control Register (PCR) at $0C configures lines, with bits 7 and 6 setting CA2 modes (e.g., 11 for output ) and bits 1 and 0 for CA1 input options (e.g., 10 for on low transition). The Interrupt Enable Register (IER) at $0E mirrors the Interrupt Flag Register (IFR) at $0D structure, where bits 0–6 enable specific sources (CA1, CA2, etc.) and bit 7 (1=SET, 0=CLEAR) toggles all enables; the IFR bit 7 indicates overall IRQ assertion. These bit functions enable programmable behavior without external logic, supporting diverse interfacing needs.

Pin Configuration

The MOS Technology 6522 is packaged in a 40-pin dual in-line () configuration, facilitating integration into microprocessor-based systems such as those using the 6502 family. Power connections include (+5 V supply) at pin 40 and Vss (GND) at pin 28, with the device designed for single +5 V operation and TTL-compatible logic levels across all inputs and outputs. The phase 2 clock input (φ2), essential for synchronizing internal operations, is located at pin 29. Address inputs for selecting internal registers (RS0 to RS3) occupy pins 12 through 15, enabling access to the chip's 16-byte register space via the host processor's address bus. Key peripheral signal groups are grouped logically on the package. Port A consists of bidirectional I/O lines PA7 through PA0 at pins 1 to 8, respectively, while Port B lines are at pins 30 (PB0), 31 (PB1), 32 (PB2), 33 (PB3), 35 (PB4), 37 (PB5), 38 (PB6), 39 (PB7). Handshaking and control signals include CA1 and CA2 for Port A at pins 9 and 10, and CB1 and CB2 for Port B at pins 36 and 34; these lines support interrupt inputs, handshake outputs, and serial data/clock functions for the integrated shift register. The interrupt request output (IRQ) is provided at pin 18 as an open-drain NMOS configuration, requiring an external pull-up resistor for wired-OR operation in multi-device systems. The bus interface signals ensure compatibility with the 6502's memory-mapped I/O architecture. The active-low reset input (RES) is at pin 27, the read/write control (R/W, high for read) at pin 11, and chip select inputs CS1 (active high) at pin 17 and CS2 (active low) at pin 16, allowing flexible decoding for . The bidirectional data bus (D0 to D7) connects to pins 19–26. Electrical characteristics specify TTL-compatible I/O levels, with ports capable of sourcing 1 mA and sinking 1.6 mA to support typical logic interfacing. Timing considerations are critical for reliable operation relative to the φ2 clock edge. For instance, address setup time requires a minimum of 180 ns before the positive φ2 transition, with hold time of 0 ns after, ensuring stable access during 1 MHz clocks as specified in . These parameters derive from the NMOS implementation's delays.
Signal GroupPinsDescription
Power40 (Vcc), 28 (Vss)+5 V supply and ground; levels
Clock/Address29 (φ2), 12–15 (RS0–RS3) clock and select
Port A1–8 (PA7–PA0)Bidirectional I/O; 1 mA source, 1.6 mA sink
Port B30–33,35,37–39 (PB0–PB7)Bidirectional I/O; same capabilities as Port A
Handshake Lines34 (CB2), 36 (CB1), 9 (CA1), 10 (CA2)/interrupt/serial; compatible
Bus Control27 (RES), 16 (CS2), 17 (CS1), 11 (R/W)Reset and access
Data Bus19–26 (D0–D7)Bidirectional 8-bit bus
Interrupt18 (IRQ)Open-drain output

Input/Output Ports

Port A and Port B

The MOS Technology 6522 Versatile Interface Adapter (VIA) incorporates two independent 8-bit bidirectional parallel input/output ports, designated Port A (PA0–PA7) and Port B (PB0–PB7), providing 16 general-purpose I/O lines in total. Each port operates via a dedicated output (ORA for Port A, ORB for Port B) and input (IRA for Port A, IRB for Port B), allowing software to read or write data across the pins. Directionality is configured on a per-bit basis using the Data Direction A (DDRA) for Port A and Data Direction B (DDRB) for Port B, where a logic '1' sets the corresponding pin as an output driven by the output , and a logic '0' configures it as a high-impedance input that reflects the external pin state when read. Data transfer occurs through direct CPU access to the data registers: writing to ORA or ORB asserts TTL-compatible output levels (high ≥2.4 V, low ≤0.4 V) on configured output pins, while reading from IRA or IRB captures the current input levels or latched values. Port inputs present one standard TTL load, and outputs drive one TTL load, with ports sourcing 1 mA at VOH = 2.4 V and sinking 1.6 mA at VOL = 0.4 V. PB6 and PB7 exhibit standard drive characteristics except in specific timer modes where their functionality overrides normal I/O (e.g., PB6 as pulse counter input, PB7 as timer output). Specifications here refer to the original NMOS version; CMOS variants like the W65C22 offer improved drive and speed characteristics (see Variants section). Optional input latching ensures stable data capture during asynchronous events, enabled separately for each port via the Auxiliary Control Register (ACR). Setting ACR bit 0 activates latching for Port A, storing the PA pin states into IRA upon an active edge transition on the CA1 , holding the value until the next transition or processor read. Similarly, ACR bit 1 enables latching for Port B, capturing PB states into IRB on a CB1 transition. This mechanism supports reliable peripheral interfacing without requiring continuous polling, particularly in noisy environments or with slow external devices. In practice, the ports serve versatile general-purpose I/O roles, such as driving keyboards for key matrix scanning, controlling segment displays for user feedback, or enabling memory expansion via address decoding. In implementations, Port B is frequently dedicated to system control functions, including bus handshaking (e.g., PB0 for NDAC input, PB1 for NRFD output, PB2 for output, PB6 for NRFD input, PB7 for DAV input), cassette motor and data write control (PB3 and PB4), and video enable signaling (PB5). These ports integrate briefly with the dedicated handshake control lines (CA1/CA2 for Port A, CB1/CB2 for Port B) to facilitate synchronized bidirectional data transfers in peripheral protocols.

Handshake Control Lines

The MOS Technology 6522 Versatile Interface Adapter (VIA) features four dedicated handshake control lines—CA1 and CA2 for Port A, and CB1 and CB2 for Port B—that facilitate synchronized data transfer with peripherals by supporting input detection and output signaling modes. These lines are configured through the Peripheral Control Register (PCR) at address offset $0C, which defines their operational modes, including edge-sensitive inputs for interrupt triggering or output behaviors for handshaking. CA1 and CB1 function exclusively as inputs, detecting positive or negative edges to latch data or generate interrupts, while CA2 and CB2 offer greater flexibility as either inputs (for edge detection) or outputs (for handshake or pulse generation). This setup enables the 6522 to interface with devices requiring precise timing, such as printers or modems, by coordinating data availability and acknowledgment signals. In input modes, CA1 and CB1 are programmed via PCR bit 0 (CA1) and bit 4 (CB1) to respond to negative (0) or positive (1) active s, setting corresponding bits in the Register (IFR) at offset $0D—specifically, bit 1 for CA1 and bit 3 for CB1—upon detection, which can trigger an IRQ if enabled in the Interrupt Enable Register (IER). For CA2 and CB2 in input mode, PCR bits 3-1 (CA2) and 7-5 (CB2) select negative or positive detection, setting IFR bits 0 (CA2) and 2 (CB2), respectively; an additional "independent interrupt input" (bits 001 or 011) allows these lines to generate interrupts without latching data. When configured as outputs, CA2 and CB2 support (PCR 100), where they assert low upon a CPU read/write to the associated and return high only after the input line (CA1 or CB1) detects an , or (101), generating a brief low on each access. Simple output options include driving the line low (110) or high (111) continuously. These modes ensure reliable peripheral communication without software polling in many cases. The handshake protocols supported by these lines implement full strobe-and-acknowledge sequences for bidirectional . For Port A read operations, CA1 signals "data ready" from (triggering a in Port A input upon edge), while CA2 outputs "data taken" as a or level to acknowledge the MPU's readiness. Port A also supports write handshaking, with CA2 indicating "data ready" to and CA1 receiving "data taken." For Port B, handshaking is limited to writes: CB2 outputs "data ready," and CB1 inputs "data taken," latching the output . Timing diagrams in the illustrate these sequences, ensuring compatibility with TTL-level peripherals. Such protocols were commonly used in systems for devices like parallel printers, where the 6522's s manage the STROBE (output) and ACKNOWLEDGE (input) signals. The lines connect directly to Port A and B by latching input on edges or inhibiting port access until completion. The following table summarizes the PCR bit assignments for configuring the control lines:
BitsLineMode Description
7-5CB2000: Input, negative edge
001: Independent input, negative edge
010: Input, positive edge
011: Independent input, positive edge
100: output
101: output
110: Output low
111: Output high
4CB10: Negative active edge
1: Positive active edge
3-1CA2000: Input, negative edge
001: Independent input, negative edge
010: Input, positive edge
011: Independent input, positive edge
100: output
101: output
110: Output low
111: Output high
0CA10: Negative active edge
1: Positive active edge

Timing and Serial Functions

Timers

The MOS Technology 6522 (VIA) incorporates two 16-bit down-counters, known as and , which provide flexible timing and event counting capabilities for systems based on the family. These timers count down from a loaded value to zero, generating an upon underflow, and operate at the system clock (ϕ₂) for timing . With a typical ϕ₂ of MHz, the timers offer a base of μs, enabling precise control in applications such as delay generation and periodic interrupts. Timer 1 functions as a general-purpose interval timer with multiple operating modes defined by bits 7 and 6 of the Auxiliary Control Register (ACR). In one-shot mode (ACR6=0), the timer latches the programmed value upon writing to the high-order latch and counts down to zero, producing a single interrupt and optionally a pulse output; this mode is ideal for generating fixed delays. In free-running mode (ACR6=1), the timer continuously reloads from the latches upon reaching zero, inverting the output state each cycle to create a square wave or toggle signal, which supports ongoing periodic events like real-time clock generation for second-level interrupts when loaded with an appropriate value (e.g., 1,000,000 for 1-second intervals at 1 MHz). If ACR7=1, the output appears on Port B pin 7 (PB7) as a pulse (one-shot) or square wave (free-running), overriding normal I/O control and impacting Port B functionality by dedicating PB7 to timing signals. Alternatively, with ACR7=0 and the Peripheral Control Register (PCR) configured for CA2 output, the signal routes to CA2 in pulse (one-shot) or toggle (free-running) form. The clock source for Timer 1 is always internal, derived from ϕ₂. Loading occurs by writing the low byte first to T1C-L ($04), followed by the high byte to T1C-H ($05), which transfers the latched value to the counter and initiates countdown; underflow sets Interrupt Flag Register (IFR) bit 6. Timer 2 operates similarly as a 16-bit down-counter but with only one-shot and pulse-counting modes, controlled by ACR bit 5. In one-shot mode (ACR5=0), it behaves like Timer 1's one-shot operation, counting down from the loaded value for interval timing, such as baud rate generation in serial communications by using the output to clock external UARTs. In pulse-counting mode (ACR5=1), Timer 2 decrements on each negative edge detected at Port B pin 6 (PB6), functioning as an event counter for input capture, such as tallying external pulses from sensors or switches until reaching zero. The clock source is internal ϕ₂ in one-shot mode, or external transitions on PB6 in counting mode. Outputs route to CB2 when the PCR sets CB2 as an output, providing a pulse or level signal on underflow. Loading follows the same sequence: low byte to T2C-L ($08), then high byte to T2C-H ($09), which loads and starts the counter; underflow sets IFR bit 5. In counting mode, PB6 serves as input, potentially affecting Port B I/O availability. Both timers operate at the ϕ₂ , allowing intervals up to approximately 65 ms at 1 MHz ϕ₂, and generate interrupts on underflow (IFR bits 6 for Timer 1 and 5 for Timer 2), which must be cleared by reading the low-order or writing the high-order . These features enable applications like precise delays in software loops, baud rate timing for asynchronous serial interfaces (e.g., 9600 baud via appropriate load values), and input capture for measuring widths or frequencies without CPU intervention.

Shift Register

The MOS Technology 6522 includes an 8-bit shift register designed for serial-to-parallel and parallel-to-serial data conversion, enabling bidirectional serial input/output operations integrated with the device's Port B and control lines CB1 and CB2. This register is loaded in parallel from Port B upon setting bit 7 of the Auxiliary Control Register (ACR), allowing data prepared on Port B to be shifted serially out via the CB2 pin or shifted in from CB2 to fill the register. The shifting occurs on each active clock edge, supporting LSB-first for input operations and MSB-first for output operations to accommodate standard serial protocols. The shift register's operating modes are configured via bits 4–2 of the ACR, where bit 4 determines the direction (0 for shift-in, 1 for shift-out) and bits 3–2 select the clock source. In disabled mode (ACR bits 4:2 = 000), no shifting occurs. For shift-in (ACR4=0), the modes are: T2 underflow clock (001), ϕ₂ clock (010), or external CB1 transitions (011), loading serial data from CB2 into the register. For shift-out (ACR4=1), the modes are: free-running recirculation at T2 rate (100), T2 underflow clock (101), ϕ₂ clock (110), or external CB1 clock (111), outputting data on CB2 after initial parallel load from Port B. The free-running output mode (100) recirculates the shifted data continuously after the initial 8-bit transfer. Clocking for the shift register derives from three sources: the internal system ϕ₂ clock for high-speed operations, external transitions on the CB1 pin for asynchronous serial interfaces, or underflow pulses from Timer 2 for programmable rates. These sources support serial data rates up to approximately 500 kHz, limited by the ϕ₂ frequency typically around 1 MHz in 6502-based systems, enabling efficient serial communication without additional hardware. Upon completion of an 8-bit transfer in active modes, bit 1 of the Interrupt Flag Register (IFR) is set, generating an interrupt if enabled via the corresponding bit in the Interrupt Enable Register (IER), allowing the CPU to handle the transferred data. In practice, the facilitates UART-like I/O for peripherals such as printers, modems, or simple networks, where parallel data from the system is serialized for or deserialized for , reducing the need for dedicated controllers in 6502 designs. For example, in shift-out mode clocked by ϕ₂, an 8-bit byte loaded from Port B can be transmitted serially on CB2 at the system clock rate, with CB1 optionally used for if external clocking is selected. This versatility made the 6522 popular in early systems for cost-effective expansion.
ACR Bits (4,3,2)ModeDirectionClock SourceNotes
000DisabledN/AN/ANo operation; register holds last value.
001Shift InInput (LSB first)Timer 2 underflowProgrammable rate via Timer 2.
010Shift InInput (LSB first)ϕ₂ (system clock)Serial data from CB2 loaded on ϕ₂ edges.
011Shift InInput (LSB first)CB1 (external)Clocked by CB1 transitions for async input.
100Shift OutOutput (MSB first)ϕ₂ (free-running at T2 rate)Continuous recirculation after load from Port B.
101Shift OutOutput (MSB first)Timer 2 underflowProgrammable rate via Timer 2.
110Shift OutOutput (MSB first)ϕ₂ (system clock)Serial output on CB2; initial load from Port B.
111Shift OutOutput (MSB first)CB1 (external)Clocked by CB1 for sync output.
Table derived from ACR configuration for shift register modes.

Interrupt Handling

IRQ Output Mechanism

The IRQ output of the MOS Technology 6522 is implemented as an open-drain (open-collector) NMOS driver, active low, which requires an external typically valued between 1 kΩ and 10 kΩ connected to the 5 V supply to ensure proper high-level signaling. This configuration enables wired-OR connections, allowing multiple 6522 chips or other open-drain interrupt sources to share a single line without conflict, a common practice in 6502-based systems for integrating several peripheral devices. The output exhibits low leakage current in the off state (up to 10 µA) and can sink sufficient current for reliable assertion when active. Assertion of the IRQ signal occurs when any enabled interrupt condition—such as a timer underflow or input transition—sets the corresponding bit in the Interrupt Flag Register (IFR) while the matching bit in the Interrupt Enable Register (IER) is also set to logic 1; this logical AND condition drives the output low. The signal latches in this state until cleared by processor software writing a logic 1 to the specific IFR bit (which acknowledges and resets the flag) or by asserting the device reset input. In system integration, the IRQ pin directly connects to the (IRQ) input of the 6502 , where it must be held low for at least one full 6502 clock cycle to trigger an service routine. The IRQ timing is synchronized to the falling edge of the ϕ2 system clock input, ensuring alignment with the 6502's internal timing for consistent recognition; the minimum for reliable assertion is two ϕ2 clock cycles. This prevents glitches and supports operation across clock frequencies up to 3 MHz in NMOS implementations. In variants, the W65C22S employs a totem-pole output driver for the IRQ, which provides both active high and low drive without needing a but necessitates series isolation (e.g., a ) for wired-OR multi-device setups to avoid bus contention. The subsequent W65C22N variant restores the open-drain configuration akin to the original 6522, maintaining compatibility with legacy wired-OR designs while improving power efficiency.

Interrupt Sources and Priorities

The MOS Technology 6522 Versatile Interface Adapter (VIA) features seven distinct sources, each corresponding to a bit in the Interrupt Flag Register (IFR) at address $0D. These sources include active transitions on the peripheral control inputs CA1 and CA2 (IFR bits 1 and 0, respectively), active transitions on CB1 and CB2 (IFR bits 4 and 3), underflow events from Timer 1 and Timer 2 (IFR bits 6 and 5), and completion of an 8-bit shift operation in the integrated (IFR bit 2). Bit 7 of the IFR serves as a summary , set to 1 whenever any enabled condition in bits 6–0 is active. The (IFR bit 2) can be influenced by configurations in the Auxiliary Control Register (ACR), such as modes that signal ready conditions upon completion, though no separate exists solely for ACR readiness. Interrupts are enabled via the Interrupt Enable Register (IER) at address $0E, where bits 6–0 mirror the corresponding IFR bits for individual source enabling. To enable a specific interrupt, a 1 is written to the desired IER bit (0–6) along with a 1 in IER bit 7; conversely, to disable, a 1 is written to the bit with IER bit 7 set to 0. This mechanism allows selective enabling without affecting other bits. For certain sources like the , additional mode controls in the ACR (e.g., bit 7 for serial timing) must be set appropriately to generate the condition, but the core enabling remains through the IER. Control line (CA1, CA2, CB1, CB2) are further configured in the (PCR) for edge or level sensitivity, but enabling is still IER-dependent. The 6522 implements a fixed hardware priority scheme to resolve simultaneous interrupts, ensuring only the highest-priority active and enabled source asserts the IRQ output. The priority order, from highest to lowest, is Timer 1 (IFR bit 6), Timer 2 (IFR bit 5), CB1 (IFR bit 4), CB2 (IFR bit 3), shift register (IFR bit 2), CA1 (IFR bit 1), and CA2 (IFR bit 0). Lower-priority sources are effectively masked by a higher one until the higher flag is cleared, preventing spurious assertions. This daisy-chain-like priority is resolved internally in hardware, with the IFR bit 7 reflecting the overall pending status based on the highest active enabled flag. Servicing an begins with reading the IFR to identify the active source(s), as bit 7 confirms a pending IRQ and bits 6–0 indicate specifics. Flags are cleared either by writing a 1 directly to the corresponding IFR bit (a read/bit-clear operation) or via actions: for timers, by reading the low-order byte or writing to the high-order ; for lines, by reading or writing the associated port register (ORA for CA1/CA2, ORB for CB1/CB2); and for the , by reading or writing the itself. A efficient servicing technique involves reading the IFR into the accumulator, then writing that value back to the IFR, which clears all flags that were set in the initial read (since writing 1s clears those bits), allowing the software to repeat until IFR bit 7 reads 0, thereby handling multiple pending interrupts in priority order without additional polling. As an alternative to IRQ-driven handling, software can poll the IFR periodically to detect and service conditions without relying on the line. The 6522 lacks on-chip interrupt vectoring, relying instead on the 6502 processor's fixed IRQ vector at memory addresses FFFE–FFFF. Upon IRQ assertion, the processor jumps to this location, and the service routine must read the 6522's IFR to determine and handle the specific source.

Limitations and Variants

Known Bugs

The MOS Technology 6522 Versatile Interface Adapter (VIA), particularly in its original NMOS implementations, exhibits several hardware flaws that can lead to unreliable operation in certain configurations. One prominent issue is the shift register bug, which affects serial data transfer in specific modes. In shift register mode 011—where the register shifts right under control of an external clock on the CB1 input—a falling edge on CB1 that coincides closely with the falling edge of the system clock φ2 can cause the loss of one data bit during input operations. This timing violation results in framing errors or incomplete data reception, particularly in high-speed asynchronous serial protocols such as those used for tape recording or IEC bus communication in Commodore systems. The bug arises from inadequate synchronization between the external clock and the internal φ2-dependent logic, leading designers to implement workarounds like external latches for critical applications. Another flaw involves potential register corruption during read or write accesses, stemming from the 6522's asynchronous (CS) and select decoding. In systems using processors other than the 6502, such as the , lines may change while CS remains asserted, especially during φ2 high periods when the 6522 samples the . Without stable setup times matching the 6522's requirements, this can cause indeterminate selection, resulting in reads from or writes to unintended locations and . This issue is exacerbated in multi-processor environments or those with asynchronous bus timing, as the original NMOS 6522 lacks internal synchronization for non-6502 clocking schemes. Older NMOS and early variants without enhanced CS decoding are particularly susceptible, often requiring additional for reliable operation. Interrupt-related problems also manifest in the 6522's IRQ output design. The NMOS version features an open-drain IRQ pin intended for wire-OR configurations, but it lacks bus-holding devices on pins (except possibly φ2 in some cases), causing the signal to float when not actively driven low. In shared bus setups without adequate pull-up resistors, this can lead to undefined IRQ states or failure to maintain logic levels, potentially generating spurious interrupts if noise or affects the line. Some second-source implementations, including certain early clones, inherit or worsen this by having weaker open-drain drivers without the bus hold features added in later revisions like the W65C22S. Additionally, asserting (RES) while an is active may not fully deassert the IRQ output immediately, as the reset clears most flags but leaves timers and the unaffected, possibly prolonging or re-triggering the interrupt in edge-sensitive systems. A timing quirk in the Timer 1 latch loading further complicates precise control in one-shot mode. Writing to the high byte latch (T1CH) initiates the countdown, but if the low byte (T1CL) has not been written first, the timer begins counting from an incomplete or zero value, leading to incorrect timing intervals until the low byte is subsequently latched. In one-shot operation, this can cause premature or erratic pulse generation on associated outputs like PB7, disrupting applications reliant on accurate one-time delays. The preliminary design documentation notes that writing the high byte has no effect unless the low byte is preset, highlighting the need for strict write order to avoid unintended starts. These bugs are predominantly observed in NMOS versions of the 6522 produced by , affecting serial protocols, interrupt-driven multiprocessing, and timer-based peripherals in vintage computing setups. CMOS variants from (WDC) mitigate some issues through bus-holding additions and improved decoding, though the shift register flaw persists in many unless explicitly addressed in silicon revisions.

Variants and Modern Equivalents

The Rockwell R6522 is a pin-compatible second-source implementation of the original 6522, produced using NMOS technology and retaining the core functionality for parallel I/O, timers, and shifting. It shares the same electrical characteristics and operational behaviors as the 6522, including susceptibility to certain timing-sensitive issues in multi-device bus configurations. The Synertek SY6522, another NMOS second-source variant, offers similar pin compatibility but with enhancements for higher operational speeds in certain applications, such as improved propagation delays suitable for faster 6502-based systems. In contrast, the 6526, known as the Interface Adapter (CIA), extends the 6522 design by integrating a UART for asynchronous while addressing the original timing vulnerability through revised internal logic. Western Design Center (WDC) introduced the W65C22 in the 1980s as a upgrade to the 6522, emphasizing low-power operation (typically under 10 mW) and flexible supply voltage support from 2 V to 5 V, making it suitable for battery-powered or portable 6502 designs. This variant resolves the original's register corruption issue—where rapid successive reads or writes could overwrite auxiliary bits—via improved internal latching mechanisms, ensuring in high-speed accesses. The W65C22S further refines this with inputs on key lines (such as CA1, CB1, and CB2) for enhanced noise immunity and a totem-pole output on the IRQ line, replacing the open-drain configuration to support direct logical ORing without external pull-ups in modern circuits. In the , Micro Devices (CMD) released the G65SC22, a -compatible evolution that fully eliminates the flip-flop anomaly by redesigning the logic, allowing reliable external clocking without data loss. As of 2025, the W65C22 remains in active production by WDC, available through distributors for integration into new designs. These CMOS variants serve as drop-in replacements for the original 6522 in retro computing restorations, such as and recreations, while enabling higher clock rates up to 14 MHz compared to the original's 1-2 MHz limit, thus supporting accelerated 6502 systems. They also appear in FPGA-based emulations, like FPGA cores for 6502-era machines, and contemporary hobbyist projects including single-board computers with W65C02 processors. Electrical enhancements, such as bus keeper circuits in the W65C22S, prevent floating inputs in sparsely driven systems but require attention to IRQ wiring differences when substituting for NMOS parts. For original 6522 implementations affected by the shift register issue, common workarounds include inserting software delays between clock pulses to ensure stable timing or adding an external D flip-flop (e.g., 74LS74) to synchronize the shift clock edge with the system phi2 signal, preventing bit loss during external clocking modes. In multi-bus environments, maintaining address line stability through additional hold-time circuitry avoids the register corruption problem without hardware replacement.

References

  1. [1]
    [PDF] MCS6522 VERSATILE INTERFACE ADAPTER - 6502.org
    The MCS6522 VIA provides MCS6520 capabilities, interval timers, shift register, input latching, bi-directional ports, and expanded handshaking.
  2. [2]
    W65C22 Versatile Interface Adapter - Western Design Center
    The W65C22 (W65C22N and W65C22S) Versatile Interface Adapter (VIA) is a flexible I/O device for use with the 65xx series microprocessor family.
  3. [3]
    [PDF] 6502 User's Manual - Retro Computing
    The KIM-1 and related computers use the 6522 VIA device. The. 6522 contains two 8-bit I/O ports—Port-A and Port-B. These ports are represented by bits PAO ...
  4. [4]
    Creating the Commodore 64: The Engineers' Story - IEEE Spectrum
    In the late 1970s, MOS Technology was a successful semiconductor company; its engineers had designed the popular 6502 microprocessor, and it manufactured ...
  5. [5]
    MOS 6522 Complex Interface Adapter - The 8-Bit Guy
    The MOS 6522 is used for input/output in systems like Commodore PET, VIC-20, and Apple Macintosh, and is used for disk, joystick, keyboard, and serial ports.
  6. [6]
    Vectrex Repair Help: Learn How to Fix It Yourself. - iFixit
    MOS 6522 Versatile Interface Adapter (VIA); Sound: General Instrument AY-2-8912; MCU Controlled Sound; 3-inch electrodynamic paper cone speaker. Additional ...
  7. [7]
    [PDF] Versatile Interface Adapter - 6502.org
    The SY6522 Versatile Interface Adapter (VIA) provides all of the capability of the SY6520. In addition, this device contains a pair of very powerful ...
  8. [8]
    [PDF] R6522 Versatile Interface Adapter (VIA)
    The R6522 allows positive control of data transfers between the system processor and peripheral devices through the operation of "handshake" lines. Port A lines ...
  9. [9]
    Commodore PET 2001 Computer - Zimmers.net
    View schematic, page 1 (Huge). View schematic, page 2 (Huge). View ... Ports: MOS 6520 PIA, MOS 6522 VIA. IEEE-488 edge-connector Port; 2 Commodore ...
  10. [10]
    [PDF] W65C22 (W65C22N and W65C22S) Versatile Interface Adapter ...
    Sep 13, 2010 · The W65C22 (W65C22N and W65C22S) Versatile Interface Adapter (VIA) is a flexible I/O device for use with the 65xx series microprocessor family.
  11. [11]
    pet-io-2.txt - 6502.org
    ... ACR E84B 7-6 Timer 1 control 0 = PB7 unused 0 0 = one shot 0 1 = continuous ... Port A latch 0 = disabled 1 = enabled on CA1 transition (in) The ...
  12. [12]
    [PDF] The Commodore PET revealed - primrosebank.net
    6522 registers. SECTION 5.....The IEEE port and the 6520. P 119. The 6520 and ... the port A latch enable. Bit 0 is the port A latch enable which when ...
  13. [13]
    [PDF] W65C22S Versatile Interface Adapter (VIA) - Western Design Center
    Jun 1, 2009 · For a Write Handshake, CA2 or CB2 serve as the Data Ready output and can operate in either the Handshake Mode or the Pulse Mode. The. Data Taken ...
  14. [14]
    [PDF] W65C22 (W65C22N and W65C22S) Versatile Interface Adapter ...
    Sep 13, 2010 · The W65C22S output pins do not have current limiting and can over drive circuitry connected to these pins. The original NMOS 6522 and W65C22N ...
  15. [15]
    [PDF] W65C22S Versatile Interface Adapter (VIA) DATA SHEET - 6502.org
    All W65C22S pins except PHI2 have bus holding devices. The original NMOS 6522, G65C22 and. R65C22 did not have bus holding devices. Figure 4-2 High Resistance ...
  16. [16]
    6502.org Tutorials: Investigating Interrupts
    " The 6522 data sheets will tell the significance of individual bits in ... The following example of using a 6522 VIA's timer 1 for the RTC is similar ...
  17. [17]
    [PDF] R6522 - 6502.org
    Sep 24, 1993 · Tne R6522 VIA has two 8-b.t bidirectional 170 ports (Port A and. Port ... bit 7 and ACR bit 7 must be 1 for PB7 to function as the timer.
  18. [18]
    [PDF] SY6522 - 6502.org
    This means: if the user has programmed the 6522 for latch mode, latching to occur on the negative edge of CA1, then CA1 must be high for a minimum TAL before ...Missing: VIA | Show results with:VIA
  19. [19]
    The Versatile Interface Adapter - waveguide.se
    May 4, 2015 · The 6522 is familiar to anyone working with the 6502 or MOS/Commodore machines. In general it's a souped up 6821 with two timers and a shift register.
  20. [20]
    I/O - 6502
    The 6522 is known as a VIA, Versatile Interface adapter. This acts as an interface between the computer and the peripheral.
  21. [21]
    [PDF] r6522 versatile interface adapter (via) - Bitsavers.org
    The R6522 VIA adds two powerful, flexible Interval Timers, a serial-to-parallel/parallel-to-serial shift register and input latch- ing on the peripheral ...
  22. [22]
    via shift register bug - stardot.org.uk
    Feb 20, 2021 · As far as I understand, the bug is only present in MOS 6522s not in the Synertek or Rockwell 6522s which are typically found in the BBC Micros.MMC failed 6522 check?6522 works in IC3 but not in IC69More results from stardot.org.uk
  23. [23]
    Could the Commodore 64 have used the 6522 VIA instead of the ...
    Sep 20, 2019 · The Commodore 64 used what appears to be basically a new and improved version of the VIA, the 6526 CIA. This fixed the shift register bug.Why did the Vic-20 need special chips for I/O?Why did so many early microcomputers use the MOS 6502 and ...More results from retrocomputing.stackexchange.com
  24. [24]
    6502.org • View topic - Is this the known 6522 shift register bug?
    Jan 22, 2010 · We early PET/CBM freaks knew, from playing music, that there was something wrong with the 6522's shift register: it interfered with other ...
  25. [25]
    [PDF] G65SC22PI-4 - California Micro Devices - Datasheet.Live
    Product Description. The CMD G65SC22 Versatile Interface Adapter (VIA) is a flexible I/O device for use with the CMD G65SCXXX series 8-bit.Missing: variant | Show results with:variant
  26. [26]
    AN-004: W65C22S Replacement Notes for Obsolete VIA Devices
    The IRQB pin on the W65C22S is a standard totem pole output. It is no longer open drain and cannot be wire OR'ed. This change was made to improve the low power, ...
  27. [27]
    Homebrew Computer: Adding a 6522 VIA - Sven Krasser's Blog
    Sep 9, 2018 · I've added a 6522 Versatile Interface Adapter (VIA). More specifically, it is a W65C22S. The VIA has a number of functionalities (after all, it makes a claim ...Missing: DB daisy chain
  28. [28]