My 8 bit computer now has a keyboard. Being a true DIYer, I went for the following solution:
1. C64 keyboard with it's 8 x 8 matrix
2. AVR MCU (ATMega 8515 in PLCC44) - This generates scancode events (high bit set for key up). Will eventually deal with key repeats
3. The AVR communicates to port A in a 65C22 VIA, with handshaking using CA1 and CA2
4. An interrupt routine in the MPU pulls off the scancode (acking the byte), optionally translates it to ASCII and stuffs it into a circular buffer. This routine also tracks shift and control keys for ASCII decoding.
(I did try using the synchronous serial port, but it gave me problems with corrupt data so I had to abandon that method.)
The VIA is init'd as follows:
Code: Select all
lda #0x08
sta PCR6522
lda #0x82
sta IER6522
What I would like to do next is implement bidirectional comms between the VIA and the AVR. The main reason is to be able to change the key repeat rate, but there might well be other uses. The issue is I'm not sure how to go about it. Obviously in the AVR the main loop will have to poll "something" to work out if the VIA has a byte, but I'm a bit puzzled how to configure it.
Is what I want to do even possible with just a single VIA port? If it's of use, I do have a spare bit available in the data path, since I only need 6 for the scancode plus another bit to indicate if the key is going up or down. I could use that spare bit to indicate the data direction?
If I haven't explained things properly just let me know.