I/O

VIA

For a computer to be useful, it needs a means of providing input(s) and output(s). To accomplish this, these peripherals need a way of talking to the computer. I will achieve this by using a 6522. The 6522 is known as a VIA, Versatile Interface adapter. This acts as an interface between the computer and the peripheral. As well as the 6502, the 6522 was manufactured by MOS Technology. It has been designed as an I/O port controller for the 6502, so it is an ideal choice for this project. It has a history of being used in 6502 based computers, as it was used by many big names. These include Commodore, Apple and BBC.

The 6522 contains 20 I/O lines, organised into two 8-bit bidirectional ports and four control lines. The direction of the 16 lines can be independently programmed.

I will use the 6522 to allow me to have an input and an output device. Because the 6522 has two ports, I plan to use one port for an input device and the other for an output device.

Memory map

I will be using 0x6000 for port B and 0x6001 for port A.

Clock

The 6522 requires a clock signal, which will be provided by connecting pin 25 to the clock signal that the 6502 is using. Data transfer between the 6502 and the 6522 occurs when the clock is high.

Input or output

The ports contain a data direction register, DDRA and DDRB. I plan on using port A for my input device and port B for my output device. To set the pins to inputs, a 0 must be placed into DDRA. To set the pins to outputs, a 1 must be placed into DDRB.

Conclusion

I now have a computer that can run a program and display its output on an LCD. Because the LCD used 11 connections of the PORTS of the 6522, I have only 5 left for PORT A. This will only be a problem if the other peripheral that I use needs more than 5 connections. There is a way that I could free up four connections. The LCD can be used in 4-bit mode. The advantage of this is that 4 less connections are required, the disadvantage is that it will be slower. This is because with 8-bit mode you send each byte in one go. In 4-bit mode you send one nibble and then a second. However, in practical terms this decrease in speed might not be a problem. You also need to write a bit more code.