R6522 Versatile Interface Adapter (VIA) FUNCTIONAL DESCRIPTION The internal organization of the R6522 VIA is illustrated in Figure 4. PORT A AND PORT B OPERATION The R6522 VIA has two &-bit bidirectional I/O ports (Port A and Port B) and each port has two associated control lines. Each 8-bit peripheral port has a Data Direction Register (DDRA, DDR} for specifying whether the peripheral pins are to act as inputs or outputs. A “0” in a bit of the Data Direction Register causes the corresponding peripheral pin to act as an input. A “1” causes the pin to act as an output. Each peripheral pin is also controlled by a bit in the Output Register (ORA, ORB) and the Input Register (IRA, IRB). When the pin is programmed as an output, the voltage on the pin is controlied by the corresponding bit of the Output Register. A "1" in the Output Register causes the output to go high, and a “0” causes the output to go low. Data may be written into Output Register bits corresponding to pins which are programmed as inputs. In this case, however, the output signal is unaffected. Reading a peripheral port causes the contents of the Input Register (IRA, IRB) to be transferred onto the Data Bus. With input latching disabled, (RA will always reflect the levels on the PA pins. With input latching enabled, IRA will refiect the levels on the PA pins at the time the latching occurred (via CA1). The IRB register operates similar to the IRA register. However, for pins programmed as outputs there is a difference. When read- ing IRA, the fevel on the pin determines whether a °‘0" ora °1" is sensed. When reading IRB, however, the bit stored in the out- put register, ORB, is the bit sensed. Thus, for outputs which have large loading effects and which pull an output “1"* down or which pull an output “0” up, reading IRA may result in reading a “0” when a ‘'1"' was actually programmed, and reading a ‘'1"" when a0” was programmed. Reading IRB, on the other hand, will read the ''1’* or “6” level actually programmed, no matter what the loading on the pin. Figures § through 8 illustrate the formats of the port registers. INTERRUPT ind CONTROL | FLAGS parar CATCH ry (FR) | ieee ee . “ENABLE 4 i) uT BUFFERS (ER) » | (ORA) | =, (PA) PORT A para [J DATA DIR ne pus [_ {DDRA) BUFFERS SERIPUERAL PORT A REGISTERS > | __ (PCR) | ; AUXILIARY CAt (ACR) > eeninem + CA2 FUNCTION PORT B CONTROL HANDSHAKE LATCH { LATCH CONTROL RES yp rif - SHIFT REG car RW COUNTER | COUNTER (SR) CB2 2 (TIC-H) | (TIC-L) cs —— ACES 5 TIMER 1 PORT B REGISTERS neo ———"} contRoL TIMER 2 iNPuT LATCH ne? Cratet) SuTPUT RS2 (T2t-l) | = BUFFERS i) RS3 COUNTER | COUNTER L_ | (ORB) | (PB) PORT B >» (T2C-H) | (¥2C-b} DATA DIR (DDRB) Figure 4. R6522 VIA Block Diagram