Hi all.
As I am expecting to complete timer tests within a couple of weeks, and, as I also have high hopes from what I am seeing this time, I decided to retrace my steps, back to the ports, before moving on with the next component, which would be ISR I think, as TOD and SDR are barely used on normal C64 operation.
As I have been pointed out several times, in several places, I have a big design flaw in my ports. They're not open collector, as I'm activelly pulling up the outputs. So far so good, this has worked for me (Being able to use a floppy drive with my ports whas a big milestone, quite a long time ago!) but, as I've been gaining more knowledge (ok, not a lot, but some
) I came to understand, this was a big flaw.
First alarms went of when I found some people talking about my work, in other forum, and mentioning "A killer poke" for my design. Pretty easy to see know... of course..
In a C64, ports are used to read the keyboard matrix, as you may know. Set both ports as outputs, pull one high, one low. Press a key, a Boom!. A short to ground. Yikes!
So yeah, I've been thinking of a couple of ways to amend this. @ttlworks suggested using some buffers ('125 or '126) with it's input tied to ground, that would be put in High-Z when the port had to output a 1, relying only on the external pullup to output a high value. So I went ahead, and layout a new board with this setup.
However, after further investigating... I made one (at least for me) big discovery. PortA and PortB are not the same. First clue was deeply hidden, in a readme.txt for a C64 emulator test suite. It's intented to be run on emulator to compare with the expected outputs and, when it comes to the ports. this is what I found:
Quote:
* Port A outputs high, Port B outputs (active) low.
- In this case port B always "wins" and drives port A low,
meaning both read back as 0.
* Port A outputs (active) low, Port B outputs high.
This case is a bit special and has some interesting properties:
- Usually (probably unexpectedly) port B will NOT be driven low by port A,
meaning port A reads back 0 and port B reads back 1.
- port B will be driven low (and then read back 0) only if the resistance of the
physical connection created over the keyboard matrix is low enough to allow
the required current. this is (again) usually not the case when pressing single
keys, instead -depending on the keyboard- pressing two or more keys of the same
column is required. a special case is the shift-lock key, which will also work
and which you can seperate from the normal left shift key in this configuration.
Second clue was found on an old scanned MOS6522 datasheet.
Attachment:
6522-03.gif [ 23.58 KiB | Viewed 1286 times ]
On the 6522, PortB schematic suggests it has a transistor to pull up stronger, together with a "normal" transistor acting as a pullup. This have to be the "Active and passive pull-ups" that are mentioned on the 6526 datasheet.
Third and last clue. Back in september, 2019, user fhw72
posted a die shot of a 6526. Even though I'm not able to read silicon in any way, there was something there, completely obvious.
Attachment:
ports.PNG [ 649.34 KiB | Viewed 1286 times ]
I've taken a section where we can see PA7 and PB0 together. I've colored in light red the VCC metal, light yellow GND. In the VCC metal, nexts to all PB pins, there're plenty of vias, forming what I can only guess is the active pullup. They're not there in any of the PA pins.
To have additional information, today I've put one of my original CIAs under some stress with some very simple test.
Attachment:
test.png [ 906 Bytes | Viewed 1286 times ]
I've tried with different R5 values, from infinite (No resistor) to 0, (direct connection) and the results seem to prove all the above:
Code:
R5 PA0 PB0 vPA0 vPB0
inf 0 1 0.2 2.9
1 0 2.6 0.2
100k 0 1 0.2 2.9
1 0 2.6 0.2
3k 0 1 0.2 2.8
1 0 2.3 0.3
1k 0 1 0.3 2.6
1 0 1.9 0.3
10 0 1 1.1 1.3
1 0 0.5 0.4
0 0 1 1.2 1.2
1 0 0.5 0.5
I need to dig up my most basic electronics knowledge(Shame on me, yesterday I had to google Ohm's Law
), but I should be able to find some accurate values for the pull'ups of a rial CIA, and how to best mimick them on my design.