C64: CIA borked?

  • Thread starter Thread starter bos
  • Start date Start date
  • Replies Replies 3
  • Views Views 142
Status
Not open for further replies.

bos

New member
Joined
Mar 27, 2017
Posts
86
Country
Sweden
Region
Västergötland
I'm measuring around in my C64 and found a weird thing. The keyboard connector pin 20 (COL7 / PA7) is constantly low (with the keyboard gone). All other pins (PA0-6, PB0-7) are high, which they should be according to the datasheet of the CIA-chip 6526. The only thing that's connected to keyboard connector pin 20, according to the schematics, is CIA pin 9 and U28 (4066) pin 5+13. I suspected U28 to be faulty. It isn't used for anything useful so I desoldered it, just to test. Pin 20 is still pulled low.

This could mean the CIA is borked, but here's the catch: if I connect a keyboard it works as it should. Joystick B (which shares the pins) works fine. The CIA is therefore working fine.

But still, why is pin 20 pulled low? I've retraced the motherboard and cannot find any capacitors or anything, that might be shorted. The only possibility here is that the CIA is borked, and still it's not. I have no spare CIA so I cannot replace it to test.

What's going on here?

 
All 8 data pins can be configured for either input or output. I checked the kernal ROM to see what it is initialized to and DDRA is set to %11111111 (@$FDC8 ), i.e. outputs on all 8 while the data register for port A is set to %01111111 (@$FDAB). So there you have it - PA7 is supposed to be low while PA6-PA0 are meant to be high. Port B is the one that is used for inputs.
 
Last edited:
Ah, thanks. Obviously I misread the datasheet.

But if one of them is low, how do CIA know when a key is pressed? In the info I could find it says that the CIA sends a bit on PB while reading them all on PA and if they mismatch (FF != FF), a key is pressed so CIA will scan / decode it. PB = %11111111 != PA = %01111111, meaning it will scan a key all the time?

Obviously that's not how it works, so I'm guess I'm completely confused here.
 
It will write a value with one low bit to PB to select a column and any corresponding low bit in PA means that a key was pressed in that column/row combination. It needs to go through all 8 bits in PB and read PA one at a time to scan the full keyboard so I think that PB=%01111111 is just the 'idle' value when it is not actively reading. Not sure about that though. I think it would make sense to just set PB=0 and then when PA!=$FF it means that some key was pressed and then you could proceed to scan for the key.
 
Status
Not open for further replies.
Back
Top Bottom