MOS Technology 6522
Encyclopedia
The 6522 Versatile Interface Adapter (VIA) was an integrated circuit
made by MOS Technology
, as well as second source
s including Rockwell
and Synertek
. It served as a I/O port controller for the 6502
family of microprocessors, providing the parallel I/O capabilities of the PIA
as well as timer
s and a shift register
for serial communications. The 6522 was very popular in computers of the 1980s, particularly Commodore
's machines, and was also a central part of the designs of the Apple III
, BBC Microcomputer and Apple Macintosh.
and interrupt
generation). The directions for all 16 general lines (PA0-7, PB0-7) can be programmed independently. The control lines can be programmed to generate an interrupt when activated (all four), latch the corresponding I/O port (CA1 and CB1), automatically generate handshaking signals for devices on the I/O ports, or output a plain High or Low signal.
s on the 8th bit of its respective I/O port (pin PA7 or PB7).
, run the flip-flop's Q output to the 6522's CB1 pin, and clock the flip-flop with Φ 0 or Φ 2. This infamous serial shift register bug is fixed by the CMD G65SC22.
. If the address lines changed while chip select was inactive but the phase 2 clock input was high (active), register contents could be changed despite chip select being inactive. This was fixed in some but not all of the CMOS versions.
Integrated circuit
An integrated circuit or monolithic integrated circuit is an electronic circuit manufactured by the patterned diffusion of trace elements into the surface of a thin substrate of semiconductor material...
made by MOS Technology
MOS Technology
MOS Technology, Inc., also known as CSG , was a semiconductor design and fabrication company based in Norristown, Pennsylvania, in the United States. It is most famous for its 6502 microprocessor, and various designs for Commodore International's range of home computers.-History:MOS Technology, Inc...
, as well as second source
Second source
In the electronics industry, a second source is a company that is licensed to manufacture and sell components originally designed by another company ....
s including Rockwell
Rockwell International
Rockwell International was a major American manufacturing conglomerate in the latter half of the 20th century, involved in aircraft, the space industry, both defense-oriented and commercial electronics, automotive and truck components, printing presses, valves and meters, and industrial automation....
and Synertek
Synertek
Synertek, Inc. was an American semiconductor manufacturer founded in 1973. The initial founding group consisted of Bob Schreiner , Dan Floyd, Zvi Grinfas, Jack Balletto, and Gunnar Wetlesen. The manufacturing technology was MOS/LSI...
. It served as a I/O port controller for the 6502
MOS Technology 6502
The MOS Technology 6502 is an 8-bit microprocessor that was designed by Chuck Peddle and Bill Mensch for MOS Technology in 1975. When it was introduced, it was the least expensive full-featured microprocessor on the market by a considerable margin, costing less than one-sixth the price of...
family of microprocessors, providing the parallel I/O capabilities of the PIA
Peripheral Interface Adapter
The Peripheral Interface Adapter is a peripheral integrated circuit providing parallel I/O interfacing capability for microprocessor systems. Common PIAs include the Motorola MC6820 and MC6821, and the MOS Technology MCS6520, all of which are functionally identical but have slightly different...
as well as timer
Timer
A timer is a specialized type of clock. A timer can be used to control the sequence of an event or process. Whereas a stopwatch counts upwards from zero for measuring elapsed time, a timer counts down from a specified time interval, like an hourglass.Timers can be mechanical, electromechanical,...
s and a shift register
Shift register
In digital circuits, a shift register is a cascade of flip flops, sharing the same clock, which has the output of any one but the last flip-flop connected to the "data" input of the next one in the chain, resulting in a circuit that shifts by one position the one-dimensional "bit array" stored in...
for serial communications. The 6522 was very popular in computers of the 1980s, particularly Commodore
Commodore International
Commodore is the commonly used name for Commodore Business Machines , the U.S.-based home computer manufacturer and electronics manufacturer headquartered in West Chester, Pennsylvania, which also housed Commodore's corporate parent company, Commodore International Limited...
's machines, and was also a central part of the designs of the Apple III
Apple III
The Apple III is a business-oriented personal computer produced and released by Apple Computer that was intended as the successor to the Apple II series, but largely considered a failure in the market. Development work on the Apple III started in late 1978 under the guidance of Dr. Wendell Sander...
, BBC Microcomputer and Apple Macintosh.
Input/output ports
The VIA contains 20 I/O lines, which are organised into 2 8-bit bidirectional ports (or 16 general-purpose I/O lines) and 4 control lines (for handshakingHandshaking
In information technology, telecommunications, and related fields, handshaking is an automated process of negotiation that dynamically sets parameters of a communications channel established between two entities before normal communication over the channel begins...
and interrupt
Interrupt
In computing, an interrupt is an asynchronous signal indicating the need for attention or a synchronous event in software indicating the need for a change in execution....
generation). The directions for all 16 general lines (PA0-7, PB0-7) can be programmed independently. The control lines can be programmed to generate an interrupt when activated (all four), latch the corresponding I/O port (CA1 and CB1), automatically generate handshaking signals for devices on the I/O ports, or output a plain High or Low signal.
Timers
The VIA provides two 16-bit timer/counters, which can be used in one-shot (monostable) mode, free-running (divider) mode or "pulse counting" mode, where the timer will monitor the 7th bit (PA6 or PB6) on its respective I/O port, and count how many state transitions pass by. Each timer can generate an interrupt when it reaches zero, and can also output square waveSquare wave
A square wave is a kind of non-sinusoidal waveform, most typically encountered in electronics and signal processing. An ideal square wave alternates regularly and instantaneously between two levels...
s on the 8th bit of its respective I/O port (pin PA7 or PB7).
Shift register
The VIA's shift register is bidirectional, 8 bits wide, and can run from either a timer-generated clock (from timer 2), the CPU clock, or an external source on line CB1. The serial input/output is on line CB2, and CB1 can also be programmed to output a bit clock for external devices. If the edge on CB1 falls within a few nanoseconds of the falling edge of phase 2, the CB1 edge will be ignored, so you lose a bit. Worse, you will get framing errors on subsequent data. To get around it, put the external clock signal into the D input of a 74HC74 flip-flopFlip-flop (electronics)
In electronics, a flip-flop or latch is a circuit that has two stable states and can be used to store state information. The circuit can be made to change state by signals applied to one or more control inputs and will have one or two outputs. It is the basic storage element in sequential logic...
, run the flip-flop's Q output to the 6522's CB1 pin, and clock the flip-flop with Φ 0 or Φ 2. This infamous serial shift register bug is fixed by the CMD G65SC22.
Bugs
Aside from the aforementioned shift register bug, there was a potential register corruption problem that usually only occurred in systems using the 6522 with a processor having a non-6502-like bus, such as a Motorola 68000Motorola 68000
The Motorola 68000 is a 16/32-bit CISC microprocessor core designed and marketed by Freescale Semiconductor...
. If the address lines changed while chip select was inactive but the phase 2 clock input was high (active), register contents could be changed despite chip select being inactive. This was fixed in some but not all of the CMOS versions.