1
\$\begingroup\$

I have been following the two Great Z80 Project guides and the only thing I don't get is the I/O. He uses a 6522 I/O V.I.A. and I don't quite understand the idea of I/O ports. So my question is, how do I hook more than one 6522 to the CPU so I can control more peripherals?

\$\endgroup\$
6
  • 2
    \$\begingroup\$ Z80...and a V.I.A.. oh my, are those not antique collector items? \$\endgroup\$
    – Trevor_G
    Commented Nov 9, 2017 at 14:57
  • 2
    \$\begingroup\$ The VIA is a memory addressable part, you would need to decode the address bus of the Z80 to select the appropriate VIA at the appropriate time. If you want more than that here you would need to post the schematic of what you have so we can tell you what to change. \$\endgroup\$
    – Trevor_G
    Commented Nov 9, 2017 at 14:59
  • 1
    \$\begingroup\$ @Trevor yes, though in Z80 usage it would presumably be wired in the I/O space, not the memory space. The peripheral chip itself wouldn't know the difference. \$\endgroup\$ Commented Nov 9, 2017 at 15:23
  • 1
    \$\begingroup\$ @Trevor - A very small page. IO space is only 8 bits. \$\endgroup\$ Commented Nov 9, 2017 at 18:52
  • 1
    \$\begingroup\$ @Trevor The VIA is an older part, but it's still in production by WDC -- wdc65xx.com/65xx-chips/w65c22-versatile-interface-adapter-via \$\endgroup\$
    – user39382
    Commented Nov 9, 2017 at 19:35

3 Answers 3

3
\$\begingroup\$

Wow this question certainly brings back memories. If I recall correctly, you can just use a 74HC573 octal latch IC to get you some outputs, and a 74HC244 octal buffer for input ports. You connect the latch ports to the Z80 data bus and then need to add an address demultiplexer to some of the A lines (such as a 74HC138) which allows you to choose which latch/buffer gets activated when you read or write to an address. Beyond these parts it was just a case of hooking up the correct output enable/latch pins to the Z80.

I never used the 6522 but it appears to be a sort of 'all in one' peripheral solution that includes IO ports and timers. Some consider this cheating compared to a full logic gate solution if you are after the 'full' Z80 experience.

\$\endgroup\$
7
  • 2
    \$\begingroup\$ +1 "Wow this question certainly brings back memories." yup, me too... ouch \$\endgroup\$
    – Trevor_G
    Commented Nov 9, 2017 at 15:05
  • \$\begingroup\$ Are there any simple schematics of this method being used? \$\endgroup\$ Commented Nov 9, 2017 at 15:07
  • \$\begingroup\$ Agreed on the IO part, that aircraft-carrier took up a lot of real estate for the few IO lines they provided. The timers were great though, at least at the time when CPU timers were very basic. \$\endgroup\$
    – Trevor_G
    Commented Nov 9, 2017 at 15:07
  • 1
    \$\begingroup\$ Also, the Z80 uses I/O mapped ports whereas other CPUs (and peripherals) tend to map to memory space. Hence the IORQ pin \$\endgroup\$ Commented Nov 9, 2017 at 15:09
  • \$\begingroup\$ Takes me back to 1981, when I went to Zilog in Santa Clara to learn how use their new Z8 device. I think the paint was still wet on the walls LOL. The thing I remember most was the cute little receptionist who did not know where Canada was, and responded to our comment "We are here for the Zed-8 course.." "We don't have a zed-8 course..." pause.." but we do have a Zee-8 Course... would that be it?" LOL. Bless her heart. \$\endgroup\$
    – Trevor_G
    Commented Nov 9, 2017 at 16:09
3
\$\begingroup\$

For the 6522 to work, both CS (Chip Select) pins must be active. The trick here is that CS1 is active-high and CS2 is active-low; So tie CS1 to the high side of your power supply and CS2 to the low side.

Great Z80 project goes on with I/O accesses, finding a way to bring 6522 to life every time the Z80 does an *I/O cycle. 6522's CLK2 pin is driven:

We can easily substitute the Z80's "I/O Request" (IORQ) pin, which is the pin used by the Z80 to tell the I/O chip that it needs to access I/O.

No I/O address decoding is done, which mean your single 6522 hogs the entire I/O address space. No other I/O device can be added to the bus, else you'll have a data bus conflict.
This is what chip select lines are for. He hard-wires the two CS lines (one high, the other low) to keep the single 6522 awake. If you want two 6522s on the bus, connect one of the CS lines (of each 6522) to a Z80 address line to select one or the other. And thanks for the memories.

\$\endgroup\$
0
\$\begingroup\$

I don't quite understand the idea of I/O ports.

I/O ports are like memory locations, except /IOREQ is used to select them rather than /MREQ. On the Z80 an I/O instruction such as OUT (0xFF),A or IN A,(0xFF) puts the 8 bit address 0xFF on the lower 8 address lines, then pulses /IOREQ low to select the I/O chip. This provides an I/O space with 256 locations. The Z80 can also have a 16 bit I/O space using instructions such as OUT (C),A, which puts the contents of the B register onto the upper 8 bits of the address bus.

To have multiple I/O chips on the same bus each one must be selected at a different address. For chips which only have one select line you can wire each one to a different address line and then address up to 8 chips with 8 bit I/O instructions, eg. first chip selected when A0 is low and all others high, second when A1 is low etc. With this method you must not use any address which has both A0 and A1 low or both chips would be selected at the same time, causing a bus conflict.

This is called 'partial' address decoding, which was used in many home computers such as the Sinclair ZX Spectrum and Amstrad CPC. Other computers with CPUs that have no I/O space (eg. 6502) have to address their I/O chips in memory space, and therefore usually do more complete address decoding because otherwise it would waste too much memory space.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.