I recently
was experimenting with the user port on my VIC 20 while trying not to blow it
up. The VIC20 has various Input/output
ports one of which is the user port (really, just the exposed edge of the
printed circuit board) on the back of the computer.
The user port is connected
to one of the VIC20’s two 6522 Versatile Interface Adapter (VIA) chips.In my experiments I am using the eight lines
which can be set as inputs or outputs.
The first
hurdle was figuring out how to connect my projects to the user port, luckily
suitable connectors are still available. I got mine from the brilliant The
Future was 8 Bit web Shoppe.
I made up a suitable cable using some ribbon cable and the other ends of the wires are plugged into a breadboard.
Here’s a
picture of the connector after I soldered some ribbon cable to it.
I found the binary
light display project in the Usborne Practical Things Do with a Microcomputer
book and thought I would have a go.
I simply connected a LED to each of the 8
I/O lines. The cathodes are connected via 220Ω resistor to the user port’s
ground. Some of the classic Usborne
1980s computer books are freely available to download as PDFs from here.
The software
is fairly simple. The chip controlling
the user port is a 6522 Versatile Interface Adapter (VIA). From BASIC, you can PEEK it to read an INPUT
or POKE it to set an OUTPUT.
For example:
10 POKE 37138, 255 20 FOR I = 0 TO 255 30 POKE 37136, I 40 FOR J = 1 TO 150 50 NEXT J 60 NEXT I 70 GOTO 20
Line 10 sets
the Data Direction Register (DDR) which controls whether that line will be an input
or an output and line 30 turns the individual lines on and off. Each LED lights up in a pattern of 0s and 1s
for each binary number from 0 to 255.
Having made
some LEDs flash I wondered if a seven segment display could be made to count
from 0 to 9. I took my Seven Segments of
PI board which is designed to work with a Raspberry Pi and connected it to the
user port.
I found an example in a
book called Practical Interfacing Projects with the Commodore Computers.
I had to
modify the code slightly as the circuity is different from the example given.
10 POKE 37138,255: A=37136 20 POKE A,40:GOSUB500 30 POKE A,157:GOSUB500 40 POKE A,185:GOSUB500 50 POKE A,58:GOSUB500 60 POKE A,179:GOSUB500 70 POKE A,183:GOSUB500 80 POKE A,41:GOSUB500 90 POKE A,191:GOSUB500 100 POKE A,59:GOSUB500 110 POKE A,175:GOSUB500 120 GOTO20 500 FOR I=1 TO 1000:NEXT:RETURN