Tuesday, March 20, 2012

Experiments with the 6522 VIA

In the next few blog postings I'll look at some experiments involving programming of the 6522 VIA (Versatile Interface Adaptor) chip on the Replica 1 Multi I/O Board.

6522 VIA on the Replica 1 Multi I/O Board

This is an enhanced version of the 6520 PIA (Peripheral Interface Adaptor) made by MOS Technology or the 6821 PIA on the Replica 1 (and Apple 1).

In addition to the two 8-bit parallel ports and handshaking lines of the 6520 or 6821, it also has two timers and a shift register. We'll look at some examples of things you can do with the timers.

The example code I'll show is written for the CC65 cross-assembler but can easily be adapted to other assemblers or even assembled by hand as they will all be quite short.

To start, let's define an include file that defines all of the registers on the 6522 VIA. We will use this in all our example programs. The file is called "6522.inc" and can be used from programs by adding the line:

.include "6522.inc"

Here is the file in it's entirety. You can look up the names of the registers in the 6522 datasheet. I tried to use similar names except "ORA" which conflicts with a 6502 opcode, so I used PORTA and PORTB for the port output registers. These values are only correct for the Replica 1, which addresses the chip starting at address $C200.

; 6522 Chip registers
        PORTB = $C200
        PORTA = $C201
        DDRB  = $C202
        DDRA  = $C203
        T1CL  = $C204
        T1CH  = $C205
        T1LL  = $C206
        T1LH  = $C207
        T2LL  = $C208
        T2CL  = $C208
        T2CH  = $C209
        SR    = $C20A
        ACR   = $C20B
        PCR   = $C20C
        IFR   = $C20D
        IER   = $C20E
        ORAX  = $C20F


Unknown said...

Great post and quite informative...thanks for sharing
Web Designing Company Bangalore
Web Development Company Bangalore
Web Design Company Bangalore

Unknown said...
This comment has been removed by the author.