R6522 • R6522 * Versatile Interface Adapter (VIA) Rockwell SEP 24 1993 DESCRIPTION FEATURES The R6522 Versatile Interface Adapter (VIA) is a very flexible • Two 8-bit bidirectional I/O ports I/O control device. In addition, this device contains a pair of very • Two 16-bit programmable timer/counters . powerful 16-tiit interval timers, a senal-to-parallel/parallel-to ser.al shift register and input data latching on the peripheral ports • Serial bidirectional peripheral I/O Expanded handshaking capability allows control of bidirectional data transfers between VIA's in multiple processor systems. • TTL compatible peripheral control lines The R6522 includes functions for programmed control of up to • Expanded "handshake” capability allows positive control of two peripheral devices (Ports A and B) These two program con­ data transfers between processor and penpheral devices trolled 8-bit bidirectional peripheral I/O ports allow direct inter­ • Latched output and input registers on both I/O ports facing between the microprocessor and selected peripheral units. Each port has input data latching capability. Two program­ • 1 and 2 MHz operation mable Data Direction Registers (A and B) allow selection of data direction (input or output) on an individual line basis. • Commercial and industrial temperature range versions The R6522 also has two programmable 16-bit Interval • Single + 5 Vdc power requirement Timer/Counters with latches. Timer 1 may be operated in a One- Shot Interrupt Mode with interrupts on each count-to-zero. or in a Free-Run Mode with a continuous series of evenly spaced interrupts. Timer 2 functions as both an interval and pulse coun­ ter Serial data transfers are provided by a serial-to- parallel/parallei-to-senal shift register. Application versatility is further increased by various control registers, including—the Interrupt Flag Register, the Interrupt Enable Register, the VSS = 1 40 CA1 Auxiliary Control Register and the Peripheral Control Register. PAO a 2 39 — CA2 PA1 — 3 38 b RSO ORDERING INFORMATION PA2 — 4 37 RS1 PA3 _ 5 36 =3 RS2 Part Number: PA4 6 35 =3 RS3 R6522 PA5 7 34 =3 RES PA6 ~ 8 33 = ! DO PA7 9 32 Z1 D1 PBO _ 10 31 =1 02 PB1 zz 11 30 3 D3 Temperature Range PB2 c 12 29 Z2 D4 Blank = 0°C to ♦ 70°C PB3 d 13 28 =3 D5 E = -4 0 °C to * 85°C PB4 cz 14 27 =3 D6 PBS — 15 26 =3 07 PB6 c 16 25 3 *2 Package PB7 c 17 24 Z1CS1 C = Ceramic CB1 c 18 23 — CS2 P = Plastic C82 i— 19 22 = ) R/W Vcc d 20 21 H ! IRQ Frequency No Letter = 1 MHz R6S22 Pin Configuration A = 2 MHz Figure 1. R6522 Pin Assignments Document No. 29000D47 Data Sheet Order No. D47 Rev. 9, June 1987 R6522 Versatile Interface Adapter (VIA) INTERFACE SIGNALS Figure 1 (on the front page) shows the R6522 VIA pin assign­ ments and Figure 2 groups the signals by functional interface RESET (RES) Reset (RES) clears all internal registers (except T 1 and T2 counters and latches, and the Shift Register (SR )). In the RES condition. a!l peripheral interface lines (PA and PB) are placed in the input state Also, the Timers (T i and T2), SR and inter­ rupt logic are disabled from operation. INPUT CLOCK (PHASE 2) The system Phase 2 (02) Input Clock controls all data transfers between the R6522 and the microprocessor. READ/WRITE (R/W) The direction of the data transfers between the R6522 and the system processor is controlled by the R/W line in coniunction with the CS1 and CS2 inputs When R/W is low (write opera­ tion) and the R6522 is selected, data is transferred from_the processor bus into the selected R6522 register When R/W is high (read ODeration) and the R6522 is selected, data is trans­ Figure 2. R6522 VIA Interface Signals ferred from the selected R6522 register to the processor bus open-dram configuration, thus allowing the IRQ signal to be DATA BUS (D0-D7) wire-ORed to a common m icroprocessor IRQ input line The eight bidirectional Data Bus lines transfer data between the R6522 and the microprocessor During a read operation, the con­ tents of the selected R6522 internal register are ransferred to PORT A DATA LINES (PA0-PA7) ^ the microprocessor via the Data B js lines. During a write oper­ Peripheral Data Port A is an {Wine, bidirectional bus for the trans­ ation, the Data Bus lines serve as high impedance inputs over fer of data, control and status information between the R6522 which data is transferred from the microprocessor to a selected and a peripheral device. Each Peripheral Data Port bus line may R6522 register The Data Bus lines are in the high impedance be individually programmed as either an input or output under state when the R6522 is unseiected. control of a Data Direction Register. Data flow direction may be selected on a line-by-line basis with intermixed input and out­ CHIP SELECTS (CS1, CS2) put lines within the same port. When a " 0 " is written to any bit position of the Data Direction Register, the correspond ng line Normally, the two chip select lines are connected to the micro­ will be programmed as an input. When a " I " is written into any processor address lines Trus connection may be direct or bit position of the register, the corresponding data line will serve through decoding To access a selected R6522 register, CS1 as an output Polarity of the data output is determined by the must be high (logic 1) and CS2 must be low (log c 0). Output Register, while input data may be latched into the Input Register under control of the CA1 line. All modes are progra~ REGISTER SELECTS (RS0-RS3) controlled by the microprocessor by way of the R6522 s inter­ The Register Select inputs allow the microprocessor to seiect nal control registers. Each Peripheral Data Port line represents one of 16 internal registers within the R6522 Refer to Table 1 one TTL load in the input mode and will drive one standard TT|_ for Register Select coding and a functional description load in the output mode A typical output circuit for Peripheral Data Port A is shown in Figure 3. REGISTER SELECTS (RS0-RS3) The Register Select inputs allow the microprocessor to select PORT A CONTROL LINES (CA1, CA2) one of 16 internal registers within the R6522. Refer to Table 1 for Register Select coding and a functional description. Control lines CA1 and CA2 serve as interrupt inputs or hand­ shake outputs for Peripheral Data Port A Each line controls z~ INTERRUPT REQUEST (IRQ) internal Interrupt Flag with a corresponding Interrupt Enable b ' CA1 also controls the latching of Input Data on Port A. CA1 is The Interrupt Request (IRQ) output signal is generated whenever a high impedance input, while CA2 represents one standard TTL an internal Interrupt Flag bit is set and the corresponding Inter­ load in the input mode In the output mode. CA2 will d n v c ^ fe rupt Enable bit is a Logic 1. The Interrupt Request output is an standard TTL load. 2 R6522 Versatile Interface Adapter (VIA) PORT B DATA LINES (PB0-PB7) PORT B CONTROL LINES (CB1. CB2) Peripheral Data Port B is an 8-line. bidirectional bus which is Control lines CB1 and CB2 serve as interrupt inputs or hand­ controlled py an Output Register. Input Register and Data Direc­ shake outputs for Peripheral Data Port B Like Port A. these twc tion Register in a manner much the same as Data Port A With control lines control an interna! Interrupt Flag with a correspond­ respect to Port B the output signal on line PB7 may be con­ ing Interrupt Enable bit Similar to CA1, CB1 controls the latch­ trolled by Timer 1 while Timer 2 may be programmed to count ing of input data on Port B These lines also serve as a se ra pulses on the PB6 line Port B lines represent one standard TTL data port under control of the Shift Register (SR) Each control load in the input mode and will drive one TTL load in the output line represents one standard TTL load in the input mode and mode. Port B lines are atso capable o’ sourcing 1.0 mA at can drive one TTL load in the output mode. CB2 can also drive 1.5 Vdc in the output mode This allows the outputs to directly a Darlington transistor circuit, however. CB1 cannot. drive Darlington transistor circuits A typical output circuit for Port B is shown in Figure 3. Table 1. R6522 Register Addressing Register RS Coding Register Register Description Number RS3 RS2 RSI RSO Desig Write ( R f f = L) Read (R W = H) 0 0 0 0 0 o r e ir b Output Register B Input Register B 1 0 0 0 1 ORA. IRA Output Registe' A Input Register A 2 0 0 1 0 DDRB Data Direction Registe' B 3 0 0 1 1 DDRA Data Direction Register A 4 0 1 0 0 T lC -L T 1 Low-Order Latches T 1 Low-Order Counter 5 0 1 0 1 T1C-H T1 High-Oraer Counter 6 0 1 1 0 T1L-L T1 low-O'der Latches 7 0 1 1 1 T1L-H T 1 High-Order Latches 8 1 0 0 0 T2C-L T2 Low-Order Latches T2 Low-Order Counte' 9 1 0 0 1 T2C-H T2 High-Order Counter 10 0 1 0 SR Shift Register 11 1 c 1 1 ACR Auxiliary Control Registe' 12 1 1 0 0 PCR Peripheral Control Register 13 1 1 0 1 IFR Interrupt Flag Register 14 1 1 1 0 IER Interrupt Enable Register 15 1 1 1 1 ORA IRA Output Registe' A* Input Register A ' NOTE: ‘Same as Register 1 except no handshake *5 V ♦ 5V INPUT OUTPUT PA0-PA7. CONTROL C H CA2 PB0-PB7, CB1. CB2 I/O CONTROL OUTPUT DATA OUTPUT _ i_ DATA - INPUT DATA INPUT DATA a Port A Output Circuit b. Port B Output Circuit Figure 3. Port A and B Output Circuits R6522 Versatile Interface Adapter (VIA) FUNCTIONAL DESCRIPTION Register brts corresponding to pins which are programmec as inputs In this case however, the output signal is unaffected The internal organ zatior o‘ the R6522 VIA is illustrated in Figure 4 Reacing a peripheral port causes the contents of the Inpu^ Register (IRA. IRB) to be transferred onto the Data Bus With input latching disabled IRA will always reflect the levels on the PORT A AND PORT B OPERATION PA pins With input latching enables. IRA will reflect the levels on the PA pins at the time the latching occurred (via CA1) Tne R6522 VIA has two 8-b.t bidirectional 170 ports (Port A and Port Bj and each port has two associated control lines The IRB register operates similar to the IRA register However, for pins programmed as outputs there is a difference When read­ Each 8-bit penphe'ai port has a Data Direction Register (DDRA. ing IRA, the level on the pin determines whether a "O' or a " V DDRBj for specifying whether tne penphe'ai pins are to act as is sensed- When reading IRB, however, the bit stored in the out­ inputs or outputs A " 0 " in a bit of the Data Direction Register put register, ORB, is the bit sensed Thus, for outputs which have causes the corresponding peripheral pin to act as an input. A "1 " large loading effects and which pull an output "1 ” down or which causes the pin to act as an output pull an output ” 0 " up. reading IRA may result in reading a " 0 " when a " 1 ” was actually programmed, and reading a " 1 " when Each peripheral pin is aiso controlled by a bit in the Output a "O’ was programmed Reading IRB. on the other hand, will Register (ORA. ORB) and the Input Register (IRA. IRB) When read the “ 1” or " 0 " level actually programmed, no matter wha: the pm is programmed as an output, the voltage on the pin is the loading on the pm controlled by the correspondng bit o* 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 Figures 5 through 8 illustrate the formats of the port registers INTERRUPT IRQ CONTROL INPUT LATCH (IRA) OUTPUT /•----- > \ BUFFERS (ORA) — ■ (PA) DATA DIR (DORA) PORT A REGISTERS PERIPHERAL —N. (PCR) AUXILIARY CA1 PORT A (ACR) CA2 FUNCTION PORT B CONTROL HANDSHAKE LATCH LATCH CONTROL (T1L-H) (T1L-L) - a I SHIFT REG CB1 COUNTER COUNTER (SR) CB2 (T1C-H) (T1C-L) TIMER 1 PORT B REGISTERS INPUT LATCH TIMER 2 (IRB) LATCH (T2L-L) OUTPUT BUFFERS COUNTER COUNTER (ORB) ; : (PB) PORT B (T2C-H) (T2C-L) "d a t a " D lV " (DORB Figure 4. R6522 VIA Block Diagram A R6522 Versatile Interface Adapter (VIA) HANDSHAKE CONTROL OF DATA TRANSFERS port. This signal normally interrupts the processor, which then reads the data, causing generation of a "D ata Taken" signal The R6522 allows positive control of data transfers between the The peripheral device responds by making new data available system processor and peripheral devices through the operation This process continues until the data transfer is complete of "handshake" lines Port A lines (CA.1 . CA2) handshake data on both a read and a write ope'ation while the Port B lines (CB1. In the R6522. automatic "R e a d " Handshaking is possiole on CB2) handshake on a write operation only the Peripheral A port only. The CA1 interrupt input pin accepts the "Data Ready" signal and CA2 generates the "Data Taken" Read Handshake signa! The "D ata R eady" signal will set an internal flag which Positive control of data transfers from peripheral devices into may interrupt tne processor or which may be polled under pro­ the system processo' can be accomplished very effectively using gram control. The "D a ta T aken" signal can either be a pulse Read Handshaking In this case, the peripheral device must or a level which is set low by the system processor and is clearec generate the equivalent of a “ Data Ready" signal to the by the "Data Ready" signal. These options are shown in Figure 9 processor signifying that valid data is present on the peripheral which illustrates the normal Read Handshake sequence Figure 5 Output Register B (ORB), Input Register B (IRB) Figure 6. Output Register A (ORA), Input Register A (IRA) REG 2—DDRB REG3—ODRA 1LU *AC I ■ »B 2 ’• 3 DATA DIRECTION DATA DIRECTION . »«4»«C REGISTER "B (DDRB) REGISTER " A " (DDRA) . »A(j , *9 ? *A 7J 0 ASSOCIATED PS Pi M S AN INPUT ASSO CIATED PA PtN IS AN INP l T (MK>* '-MPEOANCE (HtGM IMPEDANCE ■ ASSOCIATED P 8 P*N »S AN OUTPUT ASSO CIATED p a PIN IS AN O UTPUT * h O S c LEVEL « D E ^E P M iN cC B> WHCSE LEVEL IS DETERM INED B * ORB REGISTER O RA RE G iS TEP 6 T Figure 7. Data Direction Register B (OORB) Figure 8. Data Direction Register A (DDRA) R6522 Versatile Interface Adapter (VIA) DATA READY -n - _C (CA1) -(9- IRQ OUTPUT READ IRA OPERATION "DATA TAKEN HANDSHAKE MODE (CA2) • DATA TAKEN" PULSE MODE 1_____ T (CA2) Figure 9. Read Handshake Timing (Port A Only) Write Handshake The sequence of operations which allows handshaking data from the system processor to a peripheral device is very similar to that described for Read Handshaking However, tor Write Hand­ shaking. the R6522 generates the "Data Ready” signal and tne REG 12—PERIPHERAL CONTROL REGISTER peripheral device must respond with the "D ata T aken" signal. This can be accomplished on both the PA port and the PB port E E on the R6522. CA2 or CB2 act as a “ Data Ready" output in either IT ■ p M - CAf LATC*W«TfH»*u»-r CONTHOC the handshake mode or pulse mode and CA1 or C81 accept 7 ft % »A *»0 * 0 - Hk C A t I V | A C T l V t IO G C | the “ Data Taken" signal from the peripheral device, setting the 0 a 0 IM P llV M C C A T lV ft A C T l V t t O C f » • * O S * T i v l A C T I V I |£ > C 1 I 0 9 1 iM C X P f % 0 € * T M » T t M H u » T CAJ interrupt flag and clearing the “ Data Ready" output. This •* P \ ,T lO G I* 0 1 i « * U T » O S 1 T IV ! A C T iv f ID G I y 2T » 0 P t » * T i 0 % sequence is shown in Figure 10 3 1 « » * O t * l * O C * T l«* U I»«»u P T 0 0 3 •••P U T M G A T I V i A C T IV I I O C I •M U T PCS I D G f * 011 i% 0 « P f * D t * T % * |A « C » T j 0 0 0 M A * C * »«A R i O UTPUT m Latching I » 0 P U L S I O UTPUT 0 1 0 •M u T M G iO C f* l* P v T » O r » T lV l A C T lV l I O C f ^ 1 1 0 lO » o u tpu t 0 i% O iP tN D f« tT n n a a - v » ! The PA port and the PB port on the R6522 can be enabled in t’ ’ • *tG H O c T P ljl It » O i IO C f* 1 •3 0 M A H C H M A IE O U T * U r C®' LATC'V’NTERAu**- c o m t r o c - the Auxiliary Control Register (Figure 14) to be latched by their 1 io N P W i.« O U T P U T 9 • M C A liv I A T T .v l tO C t [ 1 N 'o lO « O u T fu l individual port control lines (CA1, CB1). Latching is selectable » • PQ S«T»Vt A C T iy f I P C I I 1 O W VPul to be on the rising or falling edge of the signal at each individ­ •S E E « Tt > * » ual port control line. Selection of operating modes for CA1, CA2, CB1 and CB2 is accomplished by the Peripheral Control Register Figure 11. Peripheral C on trol R egister (PCR) (Figure 11). WRITE ORA ORB OPERATION “ DATA READY” HANDSHAKE MODE (CA2, CB2) DATA READY PULSE MODE (CA2. CB2) "DATA TAKEN (CA1, CB1) IRQ OUTPUT Figure 10. W rite Handshake Tim ing 6 R6522 Versatile Interface Adapter (VIA) COUNTER/TIMERS disables any further interrupts and automatically transfers the contents of the latches into the counter and continues to decre­ There are two independent 16-b t counter/timers (called Timer 1 ment. In addition, the tim er may be programmed to invert the and Timer 2) In the R6522 Each tin e r is controlled by writing • bits into the Auxiliary Control Reg ster TS l O O ED n TO T i h i G h -ORDE® TRANSFERRED in t o »OW ORDEF wA^CHES a l SC a t T h is T im e 8 C T h CO UNTER a ’ THE '*M E t h e wrG HIGH- AND wOW-ORDER wATCMES O R O E^ CO UNTER IS l O a DED »REG 5 T RANSFERRED in t o T^ COUNTER RE AC - 8 BITS FRO M l O w -ORCER COUNTER T i IN -^ R R U P ’ F l a g a l s o is r e s e ^ TRANSFERRED TC M P l n a d o p t io n READ - 8 I0T S FRO M T i m i G h -ORDER COUNTER T« INTERRUPT FLAG S R E S E " 'B 'T 8 t r a n s f e r r e d to m pu IN i n t e r r u p t F l a g REG*ST£ c Figure 13. Timer 1 (T1) Counter Registers 7 R6522 Versatile Interface Adapter (VIA) REG 11—AUXILIARY CONTROL REGISTER T 1 T iM l P C O N T R O i - .iT C H { M 9 if D*S A 0 t f 7 6 O P E R A T IO N PB' Q = D tS A B L l C 0 TiM IO N T 6 A R u *T i f *4-8'. t LATCHING E A C * T i M t T I IS I CA01 D 0 IS A 8 1 ( 0 0 T c o n » n u o o & i * T E A flu P T S 1 0 T iM E O i * T f A R U ? ’ O N IS M O T 1 AC M T im e t i (S 0 < J T *U T S H tF T A E G lS T E A C O N T A O L LO ADED 4 3 D *E A A T i ON 1 C O N T IN U O U S SOUAAE 0 0 0 D IS A B L E D IN T E A A U A T * *A V E O UTPUT 0 0 1 S H .'F T fN J N O E A C O N T A O L O f T ? 0 1 0 S h iF ^ IN U N C E ® C O * T R C l O f 92 T? T lM f « C O *» T » O l 1 : SHI F T I * CNCE A C O N TR O L O 5 1 * T C LK 5 0*EAaTiON i 3 0 S H IF T O U T F R E E A jN N f N C A T 17 A A T f 0 T .M fc Q i n T E A A U » t j I j 0 1 S H IF T O U T U N C E R C O N T R O L O f 12 1 C O U N * D O * N WMTm ■ 1 1 1 0 S H IF T O U "r U N D E R C O N T R O L O F §2 *» U L S E S O N * B 6 I i [ * 1 FT O U T UNOE A C O N T R O L 0 » E * T C».A Figure 14 A uxiliary C ontrol R egister (ACR) Timer 1 One-Shot Mode The Timer 1 one-shc? mo<3e generates a single interrupt ‘or each that the low order latch contains the proper data before initiat­ tim er load operation As with any interval timer, the delay ing the count-down with a “ write T1C-H" operation. When the between the write T lC -H ’ operation and generation of the proc­ processor writes into the high order counter (T1C-H). the T1 inter­ essor interrupt is a direct function of the data loaded into the rupt flag will be cleared, the contents of the low order latch will timing counter. In addition to generating a single interrupt. be transferred into the low order counter, and the timer will begin Timer 1 can be programmed to produce a single negative pulse to decrement at system clock rate If the PB7 output is enabled, on the PB7 peripheral pin With the output enabled (ACR7 = 1) this signal will go low on the falling edge of 02 following the a "w rite T iC -H " operation will cause PB7 to go low. PB7 will write operation. When the counter reaches zero, the T1 inter­ roturn high when Timer 1 times out The result is a single pro­ rupt flag will be set. the IRQ pin will go low ( in t e ^ f e grammable width pulse enabled), and the signal on PB7 will go high. At this tim e ^ re Timing for the R6522 interval timer one-shot modes is shown counter will continue to decrement at system clock rate. This in Figure 15 allows the system processor to read the contents of the coun­ ter to determine the time since interrupt. However, the T 1 inter­ In the one-shot mode, writing into the T lL -H has no effect on rupt flag cannot be set again unless it has been cleared as the operat on of Timer 1. However, it will be necessary to assure descrioed in this specification. N + 1.5 CYCLES Figure 15. Timer 1 One-Shot Mode Timing 6 R6522 Versatile Interface Adapter (VIA) Timer 1 Free-Run M od e the time-out can be prevented completely it the p'ocessc' con­ tinues to rewrite the timer before it reaches zero Timer i will operate in this manner if tne processor writes into the high order J h e nos: impo'tant advantage associated with the latches in T i counte’ (T1C-H) However, by loading tne latches only, the the ability to produce a continuous series of eventy spaced processor can access the timer during each down-counting ope'- mterruots and the ability to produce a square wave on PB7 whose ation without affecting the time-out in process. Instead, the data frequency is not affected by variations in the processor inte’ r jp t loaded into the latches will determine the length of the next time­ response time. This is accomplished in the "free-r j r n ng mode out period This capability is particularly valuable in the free- runmng mode with tne output enaoled In this mode the signal In the free-running mode, the interrupt flag ;s set and the signa’ on PB7 is inverted and the interrupt flag is set with each tim e­ on PB7 is inverted each time the counter reaches zero at which out By respond ng to the interrupts with new data for the latches, . time the timer automatically transfers the contents of the latch the processor can determine the period of the next half cycle into the counter (16 bits) and continues to decrement from tnere during each half cycle of the output signal on PB7 In this manner, The interrupt flag can be cleared by writing T1C-H or T1L-H. by very complex waveforms can be generated reading T1C-L. or by writing directly into the flag as described • late' However, it is not necessa'y to rewrite the timer to enable A precaution to take in the use of PS7 as the tim er output con­ setting the interrupt flag on the next time-out cerns the Data Direction Register contents for PB7. Both DDRB bit 7 and ACR bit 7 must be 1 for PB7 to function as the timer All interval timers in the R6522 are "re-tnggerable" Rewriting output. If one is 1 and other is 0. then PB7 functions as a nor­ the counter will always re-mitialize the time-out period. In fact. mal outp>n p T C l * B T 0 A N D A RE S H IF T E D TC W A R D S B T 7 Figure 20. Shift Register Figure 21. Shift Register Modes «jinnnnimnnnnnnju¥innnnnnnnnniuinnnnn. WRITE OR READ SHIFT REG __ n____ _N ♦ 2 CYCLES ---------- — N ♦ 2 - - CYCLES________ _ CB1 OUTPUT SHIFT CLOCK ---------- l _ _ t "I 2J i 3J CB2 IN P U T ' DCDC ------------ ) c o c 7 : YT\ DATA IRQ Figure 22. SR Mode 1 — Shift In Under T2 Control 11 R6522 Versatile Interface Adapter (VIA) SR Mode 3 — Shift In Under CB1 Control the shifting operation (Figure 25). Since the Shift Register bit 7 In mode 3. external pin CB1 becomes an input (Figure 24). This (SR7) is recirculated back into bit 0, the 8 bits loadec into the allows an external device to load the shift register at its own pace. shift register will be clocked onto CB2 repetitively In this m c ^ The shift register counter will interrupt the processor each time the shift register counter is disabled 8 Pits have seen shifted in The shift registe- stops a*ter 8 counts and must be reset to start again. Reading or writing the Shift Register resets the Interrupt Flag and initializes the SR counter SR Mode 5 — Shift Out Under T2 Control to count anotner 8 pulses In mode 5, the shift rate is controlled by T2 (as in mode 1) The Note that the data is shifted during the first system clock cycle shifting operation is triggered by the read or write of the SR if following the positive-going edge of the CB1 shift pulse. For this the SR flag is set in the IFR (Figure 26). Otherwise the first shift reason, data must be held stable during the first full cycle fol­ will occur at the next time-out of T2 after a read or write of the lowing CB1 going high The minimum CB1 positive pulse width SR. However, with each read or write of the shift register the SR must be one clock period Counter is reset and 8 bits are shifted onto CB2 At the same time, 8 shift pulses are generated on CB1 to control shifting in SR Mode 4 — Shift Out Under T2 Control (Free-Run) external devices. After the 8 shift pulses, the shifting is disabled, Mode 4 is very similar to mode 1 in which the shifting rate is the SR Interrupt Flag is set and CB2 remains at the last set by T2 However, in mode 4 the SR Counter does not stop data level. •’juuuuuuiminnnnnjuuuuuuuuuumjuinjuum; READ S R _ n__________________________ CB1 O U T P U T ------- SHIFT CLOCK u u u u u u u u C 8 2 IN P U T X i X 2 X 3 X « X s X 6 X 7 X « X IRQ I ------------------- Figure 23. SR Mode 2 — Shift In Under 02 Control «jinnnnnnnnnjuiiuijuuinnnnnnjmnnnnnnjui CB1 INPUT" SHIFT CLOCK L _U L i_ l L CB2 in p u t : — , DATA i IRQ Figure 24. SR Mode 3 — Shift In Under CB1 Control I I WRITE SR JT N + 2 CYCLES CB1 OUTPUT SHIFT CLOCK C B 2IN P U T DATA J Figure 25. SR Mode 4 — Shift Out Under T2 Control (Free-Run) 12 R6522 Versatile Interface Adapter (VIA) SR Mode 6 — Shift Out Under 02 Control Interrupt Flag each time it counts 8 pulses but it does not disa­ ble the shifting function Each time the microprocessor, writes In mode 6, the shift rate is controlled by the 02 system clock or reads the shift register, the SR Interrupt Flag is reset and the (Figure 27) SR counter is initialized to beg n counting the next 8 shift pulses SR Mode 7 — Shift Out Under CB1 Control on pin CB1 After 8 shift pulses, the Interrupt Flag is set The microprocessor can ther. load the shift reg ster with the next byte In mode 7 shifting is controlled by pulses appl ed to the C61 of data. pin by an external device (Figure 28) The SR counter sets the SR IR Q " j _____________ Figure 26. SR Mode 5 — S hift Out U nder T2 C ontrol WRITE SR CBl OUTPUT SHIFT CLOCK CB2 OUTPUT DATA IRQ Figure 27. SR Mode 6 — S hift Out Under 82 C ontrol WRITE SR cbi in p u i i 1 r 1 i 2 i 1 SHIFT CLOCK 1----------- 1 1------------1 1----- _ u cm ouivui y x ’ X 2 X 8 IRQ Figure 28. SR Mode 7 — Shift Out Under CB1 Control R6522 Versatile Interface Adapter (VIA) INTERRUPT OPERATION function: IRQ . IFR6 x IER6 + IFR5 x IER5 -*■ IFR4 x IER4 ♦ IFR3 x IER3 ♦ IFR2 x IER2 ♦ IFR1 x lE R l - IFRO x Controlling interrupts wtthm the R6522 involves three principal IERO. ^ operations These are flagging the interrupts enabling interrupts a n d S ig naling to the processor that an active interrupts exists Note: ^ within the chip Interrupt 'lags are set in the Interrupt Flag Register (IFR) by conditions detected within the R6522 or on x = logic AND. + = Logic OR inputs to the R6522 These flags normally remain set until the The IFR bit 7 is not a flag Therefore, this bit is not directly cleared interrupt has been serviced To determine the source of an inter­ by writing a logic 1 into it. It can only be cleared by clearing all rupt. the microprocessor must exam.ne these flags m orcer. from the flags in the register or by disabling all the active interrupts highest to lowest priority as discussed in the next section Associated with each interrupt flag is an interrupt enable bit in the Interrupt Enable Register (IER) This can be set or cleared Interrupt Enable Register (IER) by the processor to enable interrupting the processor from the For each interrupt flag in IFR, there is a corresponding bit in the corresponding interrupt flag If an interrupt flag is set to a logic 1 Interrupt Enable Register (IER) (Figure 30) Individual bits in the by an interrupting condition, and the corresponding interrupt ena- IER can be set or cleared to facilitate controlling individual inter­ ble bit is set to a 1, the Interrupt Request Output (IRQ) rupts without affecting others. This is accomplished by writing will go low IRQ is an "open-collector” output which can be to the (IER) after bit 7 set or cleared to. in turn, set or clear wire-OR ed" with other devices in the system to interrupt the selected enable bits. If bit 7 of the data placed on the system processor data ous dunng this wnte operation is a 0. each 1 in bits 6 through 0 clears tne corresponding bit in the Interrupt Enable Register Interrupt Flag Register (IFR) For each zero in bits 6 through 0, the corresponding bit is In tne R6522. all the interrupt flags are contained in one register, unaffected i.e . the IFR (Figure 29) In addition, bit 7 of this register will be read as a logic 1 when an interrupt exists withm tne chip This Selected bits in the IER can be set by writing to the IER with allows very convenient polling of several devices within a sys­ bit 7 in the data word set to a 1. In this case, each 1 in bits 6 tem to locate the source of an interrupt through 0 will set the corresponding bit. For each zero, the cor­ responding bit will be unaffected This individual control of the The Interrupt Flag Register (IFR) may be read directly by the proc­ setting and clearing operations allows very convenient control essor In addition, individual flag bits may be cleared by writing of the interrupts during system operation a “ 1” into the appropriate bit of the IFR When the prooer chip select and register signals are applied to the chip, the contents In addition to setting and clearing IER bits, the contents o' of this register are placed on the data bus Br*. 7 indicates the register can be read at any time Bn 7 will be read as a logic 1, status of the IRQ output. This bit corresponds to the logic however REG 13—INTERRUPT FLAG REGISTER REG 14—INTERRUPT ENABLE REGISTER EH SET BY CLEARED BY c a ? A C r »vC EDGE RE A O C ® W R iT E REG » (O R A ,* -1 ICAI- C A 1 A C T IV E edge R£ A D O R * R lT E CAT R E G 1 tO » A CT B £ G c o m p e te • S H IFTS R E A D O R * » iT E S H If ’ R £G S x i f T REG 0 = INTERRUPT ^ CB2 - C B 2 A C T IV E EDGE R E A D O R M R iT E O R B * CB2 DISABLED C B l ----- C 6 ’ A C t iv t £ 6 ge RE A D 0 & *R > ? E ORB T im e O o T 0 * 72 R E A D T 2 LO W OR CBl T iM I R 2 ----- WR TE T? H IG H 1 « INTERRUPT T i m e ** 2 T IM E O U T O f T I R E A D T I LOW 0*» ENABLED A R TE T I H IG H T IM E R I A N * ENABLED Cl e a r a l l iN T f B R w M » N T |W R U *T S SET C l e a r • t f T h | c a 2 CB? C C M R C w IN T h e *C R IS S E L E C T E D AS N O TE S i f c C ! * lN O £ K T IS T E R R ^ P ’ T u E N RE A C NC OR 1 i f 8 . T 7 IS A 0 Tm ESEAC* > t% B tT S C t O ’ S A B iE S T M E Tnfc 0 ‘J T * u T » ( G iS T KR O R A O RB * L l NO T CORRESPONDING inTERRjM C cE A R B :’ IN S T E A D T m £ B T M j ST BE 2 IF B IT 7 IS A i T h e n E ACM -1 i n B IT S 0 - 6 E S A 0 .E S T h e C l f A R E O B ^ W R IT IN G i N T O T n E i * R AS OE SC RtBE I CO «»RESPON DING IN T E RR jR T fRtVKfcjSl* 3 \ f A R E A D O f T H IS R E G IS T E R IS DONE B iT 7 W i l l BE *1 A S C a l l O T H E « 8 < T S * I L I R E F L E C T T h E iR E s a B lE O t& A B iE S ’ ATE Figure 29. Interrupt Flag Register (IFR) Figure 30. Interrupt Enable Register (IER) 14 R6522 Versatile Interface Adapter (VIA) PERIPHERAL INTERFACE CHARACTERISTICS Symbol Characteristic Min. Max. Unit Figure V- t, Rise and Pan Time tor CA v CB1, CA2 and CB2 Input Signals — 1.0 MS — Delay Time. C ock Negative Transition to CA2 Negative Transiton (read handshake or — 10 1*5 31a 31b *CA2 puise mode) Detay Time Clock Negative Transition to CA2 Positive Transition (pulse mode) — 1.0 31 a Delay Time C A 1 Active Transition to CA2 Positive T-ansit on (handshake mode) - 2.0 **S 31b *nS2 Delay Time CIock Posit ve Transition to CA2 or CB2 Negat ve Transition 0.05 1.0 MS 3 lc . 3 ld *WHS (write handsnake) •os Delay Time Peripneral Data Valid to CB2 Negative Transition 0.20 1.5 31c. 3 ld ■p S3 Delay Time. Clock Positive Transition to CA2 or CB2 Positive Transition (pulse mode; — 1.0 US 31c Delay Time. CA1 or C B i Active Transition to CA2 or CB2 Positive Transition — 2.0 3 id (handshake mode) >2- Deiay Time Required from CA2 Output to CA1 Active Transition (handshake mode) 400 — ns 3 id tiC Setup Time Peripheral Data Va: 3 to C Ai or CB* Active Transition (input latching) 30C — ns 3 ie V C A l. C Bt Setup Prior to Transition to Arm Latch 300 — ns 3 le too*- Peripheral Data Hold After C A i. C B i Transition 150 ns 3 ie 's«i Shift-Out Delay Time — Time from o2 Failing Edge to C82 Data Out — 30C ns 31 f lSB2 Shift-ln Setup Time — Time from CB2 Data In to s — *ICS Pulse Spacing — CB1 Input Pulse 2 x Tcv 3 lh 15 R6522 Versatile Interface Adapter (VIA) PERIPHERAL INTERFACE WAVEFORMS 02 \ 0.8V \ READ IRA OPERATION CA2 2 y r "DA TA TAKEN \ 0 8V ' , (*S1 ' Figure 31a. CA2 Timing for Read Handshake, Pulse Mode Figure 31c. CA2, CB2 Timing for Write Handshake, Pulse Mode 16 R6522 Versatile Interface Adapter (VIA) Figure 31d. CA2, CB2 Timing for Write Handshake, Handshake Mode PA PB PERIPHERAL INPUT DATA CA1. CB1 INPUT LATCHING CONTROL TRANSITION Figure 31 e. Peripheral Data Input Latching Timing •2 - 0.8V CB2 SHIFT DATA (OUTPUT) K 0 8V CB1 SHIFT CLOCK (INPUT OR OUTPUT) DELAY TIME MEASURED FROM THE FIRST ©j FALLING EDGE AFTER CB1 FALLING EDGE Figure 31 f. Timing for Shift Out with Internal or External Shift Clocking 17 R6522 Versatile Interface Adapter (VIA) #2 X CB2 2 OV SHIFT DATA (INPUT) 0.8V CB1 SHIFT CLOCK (INPUT OR OUTPUT) SET UP TIME MEASURED TO THE FIRST «2 RISING EDGE AFTER CBI RISING EDGE •s w Figure 31 g. Timing for Shift in with Internal or External Shift Clocking \ CBi /T 0 V 2 0V \ SHIFT CLOCK INPUT 0.8V___________________ 0 8V / \_ r*-------------------- ttcw - U----------------- lt c s ------- - Figure 31 h. External Shift Clock Timing PB6 \ 2.0V 20V PULSE COUNT v INPUT \ \ 0 8 V ___________________ 0.8V / / ’•P* ----------- — —---------- tjps COUNTER T2 DECREMENTS HERE Figure 31 i. Pulse Count Input Timing 18 R6522 Versatile Interface Adapter (VIA) BUS TIMING CHARACTERISTICS R6522 (1 MHz) R6522A (2 MHz) Parameter Symbol Mm Max. Min. Mu Unit READ TIMING Cycle Time Tcv 1 10 05 10 Address Set-Up Time T*cp 180 — 90 _ ns Address Hold Time T*CAA 0 — ns o 300 _ 150 — ns Peripheral Data Set-Up Time a Data Bus Delay Time Tc w - 365 - 190 ns Data Bus Hold Time 10 - 10 ns WRITE TIMING Cycle Time To 1 10 050 10 Swise W'dtn Tc 470 - 235 - ns Address Set-Up Time f*Cv< 180 _ 90 ns _ Address Hold Time Tcav* o — 0 ns R/W Sel-Up Time T 180 90 — ns j ‘wcw R/W Mold Time TCw* o _ n o - ns 200 90 _ ns | Data Bus Set-Up Time T3CW - Data Bus Hold Time 10 10 - | ns Periphera Data Delay Time TCPW 1.0 - OS | »s Penpnera! Data Delay Time w 2.0 10 *s to CMOS Levels ' Note: tR and tf = 10 tc 30 rs . * 19 R6522 Versatile Interface Adapter (VIA) BUS TIMING WAVEFORMS 0 i * 01 c o - Read Timing Waveforms 20 R6522 Versatile Interface Adapter (VIA) ABSOLUTE MAXIMUM RATINGS* Parameter Symbol Value Unit 1 "NOTE: Stresses above those listed under ABSOLUTE MAX­ IMUM RATINGS may cause permanent damage to the device Supply Voltage Vcc - 0 3 tc - 7 . 0 Vdc [ This is a stress rating only and functional operation of tne device Input Voltage V,K - 0 . 3 to + 7 0 Vdc | at these or any other conditions above those indicated in the Operating Temperature other sections of this document rs not implied Exposure to abso­ Commercial T* 0 to + 7 0 °C lute maximum rating conditions for extended periods may affect Industrial - 40 to + 85 °c device reliability. Storage Temperature T stg - 5 5 tc + 15C eC OPERATING CONDITIONS Param eter Symbol Value Supply Voltage v cc 5V + 5% Temperature Range T* Commercial 0 * 0 to 70®C J DC CHARACTERISTICS (Vcc “ 5 0 Vdc t 5^ . v ss = 0, TA = T l to TH, unless otherwise noted) --------- i Parameter Symbol Min. Typ.3 Max. Untt | Teat Conditions Input High Voltage vw 24 — v cc V Input Low Voltage u -0 3 04 V VIL — Input Leakage Current U — ±1 ± 2 .5 *A V * - 0V to 5.25V R/W. RES. RS0. R S I, RS2. RS3, CSV CS2, CA1, 92 Vcc - o v Input Leakage Current for Three-State Oft K si — ±2 ± 10 *A V,N - 0 4V to 2.4V D0-DC7 Vcc - 5.25V Input Hign Current -1 0 0 -2 0 0 — V,h - 2 4V PA0-PA7. CA2. PB0-P67. C B i. CBS Vcc - 5.25V Input Low Current '.L — - 0 .9 -1 8 mA Vn_ - 0.4V PA0-PA7. CA2. P80-PB7, C81. CB2 Vcc * 5 .25 V Output Hign Voltage Vo Vcc “ 4 75V All outputs 24 — — V ItOAO “ — PBO-P87, CB2 (Darlington Drive) 1.5 V lL 0 AD “ —1.0 mA Output Low Voltage VOL — — 04 V Vcc - « 75V ^LO A D “ • ® mA Output High Current (Sourcing) Logic -1 0 0 -1 0 0 0 mA V0„ - 2 4V PB0-P87, CB2 (Darlington Drive) -1 .0 -2 .5 -1 0 mA V o* - 1.5V Output Low Current (Sinking) *Ol 1.6 — — mA Vql . 0 4V O utput Leakage Current (Off State) tO F F 4 ±10 Vqh ■ 2 4V IRQ Vcc “ 5.25V Power Dissipation P= — 450 700 mW Input Capacitance c* Vcc “ 5 0V R/W. RES. RS0, R S I. RS2. RS3. CS1, CS2 — 7 pF VIN - OV D0-D7. PA0-PA7, CA1, CA2. PB0-PB7 C B I. CB2 — 10 pF f - 1 MHz 92 Input 20 pF T* . 2 5 °C Output Capacitance C oin — I - 10 pF 1 i Notes: v All units are direct current (DC) except tor capacitance 2 Negative sign indicates outward current How, positive indicates inward flow 3 Typical values shown for VK = 5.0V and TA » 25°C R6522 Versatile Interface Adapter (VIA) PACKAGE DIMENSIONS 40-PIN CERAMIC DIP pa 4 i i M tU J M C T tR S M CHES I I J L B pM A M IN SC 29 MAX 51 3 i UN i 96C MAX 2 C 2C I 1 t f ■ c M 86 254 1562 4 19 0 585 C 10C 0 615 0 165 0 036 0 S3 0 015 002i F 0 76 1 40 o o x C 0 55 Q 2 54 BSC 0 100 BSC M 0 76 i 78 o o x 0 070 -» F J7 nr ' Hr f r♦ J K L C 20 2 54 14 6C 0 33 4 1® IS 37 0 006 0 100 0 575 0 013 0 165 06C 5 J T . I) *N | M N 0 0 5i 10“ i 52 0 020 lO 0 06C V 40-PIN PLASTIC DIP ,- tl r - n r. n n n n r . r . n n n . n n - n n n r i ______ _ f vn DM M H JJ88 C T 1 R S Mm MAX MM M C M iS MAX A 51 28 52 32 2 0 40 2 06C • 1372 14 22 054C 0 S6C i c 3 55 soe 0 140 0200 ! 0 036 05i 0014 0 02C • F 1 02 i 52 G 04C 006C G 2 54 BSC 0 10C BSC M i 65 2 16 0 065 0065 J 020 030 0006 0012 w M p g . K L M N 305 15 2 4 BSC r 05’ lO 1 C2 3 56 0 *2C 0600 BSC T 0C 2C 10 0 14C 0G40 DIGITAL COMMUNICATIONS DIVISION REGIONAL SALES OFFICES M aado ua r*.*-a U SA - M d A t ^ n f c F ra n c f 0 ^ * a ( C om m u»*ca8cn4 Diw aicn D ^ ta ' C o m m ^rca! or-s O w m t O g iJL C o m rn . m c * o n Og®a Commc**c»ona Dannon R o t» * a » I n m M n a l 't o o * # ' in t a m a e n * R oc»w *« ir « a rn « o ra i Roona^i mwraoonai ^apa- C o LJC 4 3 1 1 . u m o o '* * R&oc 500 ’ -6 G ta a n ir* * T o o ' GA.N 16 P laoa o « 'ig Sogo Hanzomon Bctorg 8F P O B c .C E»acuT»ve C a rp u s C a o a i 13 1-7 Ko^nacrK Cn«yooa«. W c - 5 m t C A 9 2S S 8 89C: Routa 73 Tofcyo. 1C2 T a t 1714 833-46CC. 92C62 Parts _a 0 a ta n ta 2 M arilor N J 0 80 53 Fan (714) 833-4C7B T* (609 S 96-0C9I Tat d l -T. 326S^880e F a * (714* « 33 -4 3S i T *. (3 3 -V. 49-06- 3 9 -8C Pa* (609) 596 5 68 * F a r ( il- 3 ; 3263-0639 Fa» (33-1 't 4 9 -0 6 39-9C USA - S o -t n « ( v - DCom m ur'cacni 0*«s-or R o c**H USA - N o r? n« a V 5000 B 'C * Sttaa (a n d C a n a o a E ast G ar many Ogaa. 0omrrvr»c«jon* D«gsa- C o m m u n ica tio n ^ D ^ is o r D^jffas C o m m ^ ^ a io r * 4 C *v« e r, R o o i« a 8 r« a n > « B n a i S w tt 40C 3con**.i ma'naior^j R ockw all r e a m ^ o n a i G^vw-* Rm 608 _aama BuiOng ^ W a « c r C A 9 26 6C °a o t G a m a / c A 6 a * e Suitfc ’ 5 8000 M -n c f^ a r 6C SaooJ Was»C'<2 MA 0188c G ar many U S A - S o u lfta a a t Tai (5 0 6 )6 9 2 7 6 6 : Ta. 149-89: 8 2 9 -*32C O ^ t a i C o m m u n c ic 'n D m a o - Tat *2-2) 736-9121 Rocaw a t ir a s m a ic r ^ i F * . (506, 692-6 ■eb Fas (49-89:834 2734 Fa. (82-2) 736-9124 O n * C o o t** P a i*w a . Sw «a270 U Q frm v i* NC 2756C U SA - N o T if * * * * 1 H ong Kong T«i (9>9) 467-77C 3 (•"« Canada Wes; i D^ptaf Com: Ogca/ CommvxacattonaD**o- Fa» (9 1 9 46 7-6096 D ^ « a .'C o m /rr^ rc a a .c r^ D w s c RoO iwaf! n ra rn a o n jk R o o w l nw nenonai R o ot «aft * n a rr a ic '-A '3rn F o e * R o o m 2808 U S A - S o o th C entra* 36C0 P iin a r id g a A * a n o * XW UWi Ttacte Baking D^wai Comiruncaens Dtv^.c' Sol* 100 So«as 6-1C. -la rtw * ^ C a re r* 333 Kaaang Roac. Sacaon 1 25 H a ;t» R oac S o o « * i' n t * T a « y j S an ta C .ara C A 95051 W a n e t\» H ong K ong T« a T m m t 10544 20C1 N C o im s B 'vc ROC Ta1 (4C« 249-9696 S o u 103 T a (852} 8 27 -0 18 - T a t ( M S - ? 720-0282 f a» !408> 2 m i ' 8 R o - a r a s o r . TX 7506C F a . <852* 827 6488 F a r (M 6>2; 7S7«67%C Ta< C 2 i4 > 9 9 a 4 C ;: F a * (214 A w t in iia U S A - Monn C m Ira i l»a*y IM C ^ t a C o m m u n ica tio n s D*vt»o - 0*gnai C o f f m j &g«a ComtHncttoni Dwaer C0^*nuf^C««3.-TS DtVrSiOr A e O w o l tMam aBonat RoO rarai vitB m a o o n a LXd Roo»*»a< «n*#rna 477 90 226 T * t J4a-6’ >5 r 1C34 CA* (706, 297-323C p 4 i (6T-2) 805-559? =ju 39 ? 4120-642 F a * ( 4 4 ^ * , 57C-C7S8 C. Roc^we rjemaiicr.ai Cfi'&crarc' 159 ’ ^ rta c it J S A 9 1 1 0 3 .1 0 0 0 9 '