I'm doing something atmega8-based that plugs to a Commodore 64 (heh) joystick port. This something causes me some unexpected trouble. C64 joystick port lines are shared with keyboard matrix lines, so screwing with them makes the keyboard malfunction. Normally keyboard is being scanned with a running 0 and joystick is being checked when keyboard is not active. Joystick is typical Atari, normally open, switches close to the ground. Joystick port 1 is connected to keyboard row lines, joystick port 2 is connected to keyboard column lines.
(for the really curious, the schematic part that shows control ports and keyboard connections is here: http://zimmers.net/anonftp/pub/c... )
My atmega8 has joystick lines connected directly to PORTC pins. The plan was to keep pullups off and lines tristated. When I'd need to imitate a switch closing, I'd write "1" to corresponding DDR bit and that will be it. Hard to imagine anything more simple than this.
But not all is well. When I plug my magic device in, C64 basically goes nuts. Namely, certain keyboard keys, probably related to one of the pins, get broken readings. This is possible, because some pullup or output could interfere. But this happens even when the entire code consists of, just to be really sure:
cli(); SFIOR |= PUD; while(1);
It keeps going on even when the device is in reset state. I checked all lines, I get at least 30MOhm to the ground on each pin.
Now I never really dealt with MOS logic before. Is there something very special about it that has to be taken care of? I don't even know where to start because I seem to have no control of the situation (except for plugged/unplugged ;) To add to curiosity, stick emulation works on some lines and on some it doesn't. Probably those that don't work are the same that are shared with keyboard lines that get affected. I'm perplexed. Any random ideas from your trick bags?
I realize this question is bordering with GE forum, but it's also very AVR-specific so I posted it here.
6526 CIA datasheet:
Says that PA/PB are TTL/CMOS compatible... Even weirder now.