Dr Jefyll wrote:
Chad, re the code you posted, can I assume that via_pa is the VIA's PortA I/O register, and via_da is the VIA's PortA Data Direction register? Just checking.
Also I had an urge to peek at your schematic, but I don't readily find anything I can immediately identify as the latest version. But you say, "my video circuit takes the 6502 offline during PHI2-low." The wording is a tad vague.
In any case, here's your diagram again, and I think you know the VIA needs stable inputs during the interval that's highlighted. *All* the VIA bus control inputs (ie; all the VIA inputs other than the 16 port lines and 4 port handshake lines) need to be stable. In particular I'm wondering about R/W aka RWB.
If you're confident that the logic ought to provide stable inputs, then we need to consider other trouble sources such as power supply noise, or construction errors (who knows, maybe a floating input that somehow got overlooked) -- you get the idea. Good luck!
-- Jeff.
Thank you Jeff. I have been pondering it all day.
1) Yes, via_pa = via+$01, and via_da = via+$03.
2) Yes, you are right, and I believe I have accounted for the need for stable inputs before the VIA's clock rises.
3) Yes, the R/W line is floating for a bit. I have a pull-up resistor on it, but it isn't needed as per the logic. It is not floating while PHI2 is high, which is when the VIA (in my configuration) will need it.
So, I can half rule out the breadboard as an issue: I just soldered a DIP-40 socket to the board and ran all the bodge wires. It is no longer resetting the VIA when reading. So there's something at least. I can still write to it without issue. Reading gives me the exact same thing: garbage. I installed a SPST switch to be able to manually turn the VIA off whenever I wanted, and I see similar garbage when I try to read while it's disabled. That is telling me that the data bus is floating when the 6502 is trying to read from it, that is the PHI2-falling edge.
Addresses and R/W need to be ready when the VIA's clock rises. I am very sure about that happening, obviously I can write to it. Data needs to be ready when the VIA's clock falls. It seems that VIA-incoming data is fine, but VIA-outgoing data is not. *sigh* Any suggestions are welcome, I'll be pondering on it more.
Thank you Jeff, and thank you all.
Chad
EDIT: I just changed the timing on the CS lines. CS1 (active high) is now active all through PHI2 high and the first half of PHI2 low. Plenty of time for the VIA to output and the 6502 to read. /CS2 (active low) is through address decoding, usual procedure. No changes. Still able to write, not able to read. The R/W line has a pull-up resistor on it, and although it 'floats' at the beginning of PHI2 low, if it were reading, it would stay high anyways. Obviously addresses are solid because I can write. And obviously the 6502 can typically read because it's RAM and ROM work perfectly fine.
Oh, and I tried a second VIA, and it was doing the exact same thing, so it's not the chip's fault.