Sunday, July 19, 2015

A CIA Mystery



My olde Trusty Commodore 128, a constant companion since the mid-1980s, recently developed a little problem.

The first sign was a locked-up IEC (disk drive) bus when booting into C128 mode, which locked up the computer as well.  If you don't know, this is possible because the C128 kernal checks for a bootable disk in device #8 at boot-time.  Anyway, the bus lock would prevent the computer from giving a prompt.  C64 mode, since it did not perform this initial check, was fine. Restarting the computer usually put things right, but it was still a concern.

Then, the other day I tried to boot the computer into Z80 (CP/M) mode.  After CP/M finished booting, I tried entering some commands to discover that the keyboard was unresponsive.  A quick check revealed that the keyboard still worked absolutely fine if the computer was booted into either C128 or C64 mode.

So, intermittent IEC bus problems, keyboard problems -- sounds like a bad I/O chip.  And in the Commodore 128, that means it has something to do with one of the two MOS 6526 CIA (Complex Interface Adapter) chips.



You can see the two CIA chips circled above.

Now, the problem could be something internal to the chip (meaning Bad Chip), or it could be that the chip is not properly seated.  There is also the question as to WHICH of the two is responsible for the problems.  Swapping them answers all those questions.  As a stroke of luck would have it, both of the C128 CIA chips are socketed! Woohoo! That means swapping is trivial.

So I swapped them.

And here's the crazy thing.  After the swap, the IEC problems went away, as did the problems with the keyboard when CP/M was booted.  However, now the keyboard is entirely non-functional in both C64 and C128 mode.

Clearly one of the CIA chips was bad, so I made an educated guess that the original bad chip was the one in the back left, replaced it, and now the computer is fine.



But what are the implications of the fact that a different CIA chip handles keyboard I/O depending on whether the Z80 or 8502 is active?

The CBM-Hackers mailing list is mostly unsure.  Bil Herd might know, so I may shoot him and email and post any updates if he has any insights.