
The 6526/8520 Complex Interface Adapter (CIA) was an
integrated circuit
An integrated circuit (IC), also known as a microchip or simply chip, is a set of electronic circuits, consisting of various electronic components (such as transistors, resistors, and capacitors) and their interconnections. These components a ...
made by
MOS Technology
MOS Technology, Inc. ("MOS" being short for Metal Oxide Semiconductor), later known as CSG (Commodore Semiconductor Group) and GMT Microelectronics, was a semiconductor design and fabrication company based in Audubon, Pennsylvania. It is ...
. It served as an
I/O port
Memory-mapped I/O (MMIO) and port-mapped I/O (PMIO) are two complementary methods of performing input/output (I/O) between the central processing unit (CPU) and peripheral devices in a computer (often mediating access via chipset). An alterna ...
controller for the
6502
The MOS Technology 6502 (typically pronounced "sixty-five-oh-two" or "six-five-oh-two") William Mensch and the moderator both pronounce the 6502 microprocessor as ''"sixty-five-oh-two"''. is an 8-bit microprocessor that was designed by a small ...
family of microprocessors, providing for
parallel and
serial I/O capabilities as well as
timers
A timer or countdown timer is a type of clock that starts from a specified time duration and stops upon reaching 00:00. It can also usually be stopped manually before the whole duration has elapsed. An example of a simple timer is an hourglass ...
and a Time-of-Day (TOD) clock. The device's most prominent use was in the
Commodore 64
The Commodore 64, also known as the C64, is an 8-bit computing, 8-bit home computer introduced in January 1982 by Commodore International (first shown at the Consumer Electronics Show, January 7–10, 1982, in Las Vegas). It has been listed in ...
and
Commodore 128(D), each of which included two CIA chips. The
Commodore 1570 and
Commodore 1571 floppy disk drives contained one CIA each. Furthermore, the
Amiga
Amiga is a family of personal computers produced by Commodore International, Commodore from 1985 until the company's bankruptcy in 1994, with production by others afterward. The original model is one of a number of mid-1980s computers with 16-b ...
home computer
Home computers were a class of microcomputers that entered the market in 1977 and became common during the 1980s. They were marketed to consumers as affordable and accessible computers that, for the first time, were intended for the use of a s ...
s and the
Commodore 1581 floppy disk drive employed a modified variant of the CIA circuit called 8520. 8520 is functionally equivalent to the 6526 except for the simplified
TOD circuitry. Predecessor to CIA was
PIA.
Parallel I/O
The CIA had two
8-bit
In computer architecture, 8-bit integers or other data units are those that are 8 bits wide (1 octet). Also, 8-bit central processing unit (CPU) and arithmetic logic unit (ALU) architectures are those that are based on registers or data bu ...
bidirectional parallel I/O ports. Each port had a corresponding Data Direction Register, which allowed each data line to be individually set to input or output mode. A read of these ports always returned the status of the individual lines, regardless of the data direction that had been set.
Serial I/O
An internal bidirectional 8-bit
shift register
A shift register is a type of digital circuit using a cascade of flip-flop (electronics), flip-flops where the output of one flip-flop is connected to the input of the next. They share a single clock signal, which causes the data stored in the syst ...
enabled the CIA to handle
serial I/O. The chip could accept serial input clocked from an external source, and could send serial output clocked with one of the built-in programmable timers. An
interrupt
In digital computers, an interrupt (sometimes referred to as a trap) is a request for the processor to ''interrupt'' currently executing code (when permitted), so that the event can be processed in a timely manner. If the request is accepted ...
was generated whenever an 8-bit serial transfer had completed. It was possible to implement a simple "
network" by connecting the shift register and clock outputs of several computers together.
The maximum bitrate is 500 kbit/s for the 2 MHz version.
The CIA incorporates a fix to a bug in the serial-shift register in the earlier
6522 VIA. The CIA was originally intended to allow fast communication with a disk drive, but in the end couldn't be used because of a desire to keep disk drive compatibility with the
VIC-20
The VIC-20 (known as the VC-20 in Germany and the VIC-1001 in Japan) is an 8-bit entry level home computer that was sold by Commodore International, Commodore Business Machines. The VIC-20 was announced in 1980, roughly three years after Commod ...
; in practice the firmware of
1541
__NOTOC__
Year 1541 ( MDXLI) was a common year starting on Saturday of the Julian calendar.
Events
January–March
* January 4 – Leonardo Cattaneo della Volta is elected to a two-year term as the new Doge of the Republic o ...
drive had to be made even slower than its VIC-20 predecessor to workaround a behaviour of the C64's
video processor, that, when drawing the screen, turned off the
CPU for 40 microseconds every 512 microseconds and in that timeslice can't listen to the bus, risking to miss some bit .
articles on c64-wiki.com
/ref>
Interval timers
Two programmable interval timers were available, each with sub-microsecond
A microsecond is a unit of time in the International System of Units (SI) equal to one millionth (0.000001 or 10−6 or ) of a second. Its symbol is μs, sometimes simplified to us when Unicode is not available.
A microsecond is to one second, ...
precision. Each timer consisted of a 16-bit
16-bit microcomputers are microcomputers that use 16-bit microprocessors.
A 16-bit register can store 216 different values. The range of integer values that can be stored in 16 bits depends on the integer representation used. With the two ...
read-only presettable down counter and a corresponding 16-bit write-only latch
A latch or catch (called sneck in Northern England and Scotland) is a type of mechanical fastener that joins two or more objects or surfaces while allowing for their regular separation. A latch typically engages another piece of hardware on the ...
. Whenever a timer was started, the timer's latch was automatically copied into its counter, and the counter would then decrement with each clock cycle until underflow, at which an interrupt
In digital computers, an interrupt (sometimes referred to as a trap) is a request for the processor to ''interrupt'' currently executing code (when permitted), so that the event can be processed in a timely manner. If the request is accepted ...
would be generated if the CIA was configured to do so.
The timer could run in either "one-shot" mode, halting after underflowing, or "continuous" mode, reloading the latch value and starting the timer cycle anew. In addition to generating interrupts, the timer output could also be gated to the second I/O port.
As configured in the Commodore 64
The Commodore 64, also known as the C64, is an 8-bit computing, 8-bit home computer introduced in January 1982 by Commodore International (first shown at the Consumer Electronics Show, January 7–10, 1982, in Las Vegas). It has been listed in ...
and Commodore 128
The Commodore 128, also known as the C128, is the last 8-bit home computer that was commercially released by Commodore Business Machines (CBM). Introduced in January 1985 at the CES in Las Vegas, it appeared three years after its predecessor, t ...
, the CIA's timing was controlled by the Ø2 system clock, nominally one MHz
The hertz (symbol: Hz) is the unit of frequency in the International System of Units (SI), often described as being equivalent to one event (or cycle) per second. The hertz is an SI derived unit whose formal expression in terms of SI base u ...
. This meant that the timers decremented at approximately one microsecond intervals, the exact time period being determined by whether the system used the NTSC
NTSC (from National Television System Committee) is the first American standard for analog television, published and adopted in 1941. In 1961, it was assigned the designation System M. It is also known as EIA standard 170.
In 1953, a second ...
or PAL
Phase Alternating Line (PAL) is a color encoding system for analog television. It was one of three major analogue colour television standards, the others being NTSC and SECAM. In most countries it was broadcast at 625 lines, 50 fields (25 ...
video standard. In the C-128, clock stretching was employed so the CIA's timing was unaffected by whether the system was running in SLOW or FAST mode.
It was possible to generate relatively long timing intervals by programming timer B to count timer A underflows. If both timers were loaded with the maximum interval value of 65,535, a timing interval of one hour, 11 minutes, 34 seconds would result.
Time-of-Day (TOD) Clock
A real-time clock is incorporated in the CIA, providing a timekeeping device more conducive to human needs than the microsecond precision of the interval timers. Time is kept in the American 12-hour AM/PM format. The TOD clock consists of four read/write registers: hours (with bit 7 acting as the AM/PM flag), minutes, seconds and tenths of a second. All registers read out in BCD format, thus simplifying the encoding/decoding process.
Reading from the registers will always return the time of day. In order to avoid a carry error while fetching the time, reading the hours register will immediately halt register updating, with no effect on internal timekeeping accuracy. Once the tenths register has been read, updating will resume. It is possible to read any register other than the hours register "on the fly," making the use of a running TOD clock as a timer a practical application. If the hours register is read, however, it is essential to subsequently read the tenths register. Otherwise, all TOD registers will remain "frozen."
Setting the time involves writing the appropriate BCD values into the registers. A write access to the hours register will completely halt the clock. The clock will not start again until a value has been written into the tenths register. Owing to the order in which the registers appear in the system's memory map
In computer science, a memory map is a structure of data (which usually resides in memory itself) that indicates how memory is laid out. The term "memory map" has different meanings in different contexts.
#It is the fastest and most flexible cach ...
, a simple loop is all that is required to write the registers in the correct order. It is permissible to write to only the tenths register to "nudge" the clock into action, in which following a hardware reset, the clock will start at 1:00:00.0.
In addition to its timekeeping features, the TOD can be configured to act as an alarm clock
An alarm clock or alarm is a clock that is designed to alert an individual or group of people at a specified time. The primary function of these clocks is to awaken people from their night's sleep or short naps; they can sometimes be used for o ...
, by arranging for it to generate an interrupt request
In a computer, an interrupt request (or IRQ) is a hardware signal sent to the processor that temporarily stops a running program and allows a special program, an interrupt handler, to run instead. Hardware interrupts are used to handle events s ...
at any desired time. Due to a bug in many 6526s (see also errata below), the alarm IRQ would not always occur when the seconds component of the alarm time is exactly zero. The workaround
A workaround is a bypass of a recognized problem or limitation in a system or policy. A workaround is typically a temporary fix that implies that a genuine solution to the problem is needed. But workarounds are frequently as creative as true so ...
is to set the alarm's tenths value to 0.1 seconds.
The TOD clock's internal circuitry is designed to be driven by either a 50 or 60 Hz sine wave
A sine wave, sinusoidal wave, or sinusoid (symbol: ∿) is a periodic function, periodic wave whose waveform (shape) is the trigonometric function, trigonometric sine, sine function. In mechanics, as a linear motion over time, this is ''simple ...
signal. As used in the C-64 and C-128(D), the computer's power supply supplied such a signal from the mains, resulting in a stable timekeeper with little long-term drift. The ability to work with both power line frequencies allowed a single version of the 6526 to be used in computers operated in countries with either 50 or 60 Hz power. It is important to note that contrary to the popular belief, NTSC
NTSC (from National Television System Committee) is the first American standard for analog television, published and adopted in 1941. In 1961, it was assigned the designation System M. It is also known as EIA standard 170.
In 1953, a second ...
or PAL
Phase Alternating Line (PAL) is a color encoding system for analog television. It was one of three major analogue colour television standards, the others being NTSC and SECAM. In most countries it was broadcast at 625 lines, 50 fields (25 ...
video standards are not directly linked to mains power frequency. Additionally, some computers did not derive their TOD clock frequency from the mains power source. For example, both NTSC
NTSC (from National Television System Committee) is the first American standard for analog television, published and adopted in 1941. In 1961, it was assigned the designation System M. It is also known as EIA standard 170.
In 1953, a second ...
and PAL
Phase Alternating Line (PAL) is a color encoding system for analog television. It was one of three major analogue colour television standards, the others being NTSC and SECAM. In most countries it was broadcast at 625 lines, 50 fields (25 ...
variants of Commodore SX-64 use 60 Hz TOD clock supplied by a dedicated crystal. KERNAL
KERNAL is Commodore's name for the ROM-resident operating system core in its 8-bit home computers; from the original PET of 1977, followed by the extended but related versions used in its successors: the VIC-20, Commodore 64, Plus/4, Commodore ...
operating system in Commodore 64
The Commodore 64, also known as the C64, is an 8-bit computing, 8-bit home computer introduced in January 1982 by Commodore International (first shown at the Consumer Electronics Show, January 7–10, 1982, in Las Vegas). It has been listed in ...
for example will determine the video standard during system startup, but tries neither to identify the supplied TOD clock frequency nor to initialise the CIAs correctly on 50 Hz driven machines. Thus, it is the responsibility of any application software that wants to use either CIA's TOD function to determine the supplied frequency and set the CIA(s) flag accordingly itself. Failure to do so may cause the clock to deviate quickly from the correct time.
The 8520 revision of the CIA, as used in the Amiga
Amiga is a family of personal computers produced by Commodore International, Commodore from 1985 until the company's bankruptcy in 1994, with production by others afterward. The original model is one of a number of mid-1980s computers with 16-b ...
and the Commodore 1581 disk drive, modified the time-of-day clock to be a 24-bit binary counter, replacing the BCD format of the 6526. Other behavior was similar, however.
Versions
The CIA was available in 1 MHz
The hertz (symbol: Hz) is the unit of frequency in the International System of Units (SI), often described as being equivalent to one event (or cycle) per second. The hertz is an SI derived unit whose formal expression in terms of SI base u ...
(6526), 2 MHz (6526A) and 3 MHz (6526B) versions. The package was a JEDEC
The Joint Electron Device Engineering Council (JEDEC) Solid State Technology Association is a consortium of the semiconductor industry headquartered in Arlington County, Virginia, Arlington, United States. It has over 300 members and is focused ...
-standard 40-pin ceramic
A ceramic is any of the various hard, brittle, heat-resistant, and corrosion-resistant materials made by shaping and then firing an inorganic, nonmetallic material, such as clay, at a high temperature. Common examples are earthenware, porcela ...
or plastic
Plastics are a wide range of synthetic polymers, synthetic or Semisynthesis, semisynthetic materials composed primarily of Polymer, polymers. Their defining characteristic, Plasticity (physics), plasticity, allows them to be Injection moulding ...
DIP. The 8520 CIA, with its modified time-of-day clock, was used in the Amiga
Amiga is a family of personal computers produced by Commodore International, Commodore from 1985 until the company's bankruptcy in 1994, with production by others afterward. The original model is one of a number of mid-1980s computers with 16-b ...
computers.
Commodore embedded reduced (just 4 registers) CIA-like logic for the cost reduced Commodore 1571 inside the C128DCR (See Commodore 128
The Commodore 128, also known as the C128, is the last 8-bit home computer that was commercially released by Commodore Business Machines (CBM). Introduced in January 1985 at the CES in Las Vegas, it appeared three years after its predecessor, t ...
) in a gate array called 5710 which also contains other functions.
The 5710 CIA has the serial clock for the fast serial interface hardwired to a CIA6526 equivalent Timer A value of 5, leading to a per-bit time of 5μs on transmission. This is different from what used to be a Timer A value of 6 in the 6526 CIA in the original Commodore 1571. The 5710 CIA does not contain timer or timer control registers. It only contains two port registers and the register to control the serial shifter and its event.
Errata
In addition to the aforementioned alarm clock interrupt bug, many CIAs exhibited a defect in which the part would fail to generate a timer B hardware interrupt
In digital computers, an interrupt (sometimes referred to as a trap) is a request for the processor to ''interrupt'' currently executing code (when permitted), so that the event can be processed in a timely manner. If the request is accepted ...
if the interrupt control register (ICR) was read one or two clock cycles before the time when the interrupt should have actually occurred. This defect, as well as logic errors in the Commodore provided (8 bit) operating system, caused frequent pseudo-RS-232
In telecommunications, RS-232 or Recommended Standard 232 is a standard introduced in 1960 for serial communication transmission of data. It formally defines signals connecting between a ''DTE'' (''data terminal equipment'') such as a compu ...
errors in the Commodore 64
The Commodore 64, also known as the C64, is an 8-bit computing, 8-bit home computer introduced in January 1982 by Commodore International (first shown at the Consumer Electronics Show, January 7–10, 1982, in Las Vegas). It has been listed in ...
and Commodore 128
The Commodore 128, also known as the C128, is the last 8-bit home computer that was commercially released by Commodore Business Machines (CBM). Introduced in January 1985 at the CES in Las Vegas, it appeared three years after its predecessor, t ...
computers when running at higher baud
In telecommunications and electronics, baud (; symbol: Bd) is a common unit of measurement of symbol rate, which is one of the components that determine the speed of communication over a data channel.
It is the unit for symbol rate or modulat ...
rates.
References
External links
MOS 6526 CIA datasheet
(GIF format, zipped)
MOS 6526 CIA datasheet
(PDF format)
{{Portal bar, Amiga
MOS Technology integrated circuits
Input/output integrated circuits
Commodore 64
Amiga