I'm following along with Ben Eater's 6502 project (ergo, I'm a newb), and all has gone pretty well until I hit a weird snag.
The breadboard-based setup has no RAM, just an EEPROM for code. And it outputs via a 6522. The first stage of the project had the computer blinking LEDs. I got that working, and even experimented somewhat with the code, with success.
The setup also involves using an Arduino Mega as a poor man's logic analyser. It monitors the 16 address lines, the 8 data lines, the RWB signal and the PHI2 clock, which it uses to trigger an interrupt prompting it to read. It then prints the state of the address and data buses, plus the RWB line, on the serial monitor.
And I need to stress that this has all been working fine.
But then the next stage was replacing the LEDs with a 16x2 LCD display. This involves only changes to the output side of the 6522. Everything to do with the 6502 and EEPROM remained the same.
The code runs fine, inasmuch as the relevant addresses and data values are appearing on the buses - when it comes to reading from the EEPROM. But when the time comes for the 6502 to write a value to the data bus, it's always 0!
Here's some sample output from the serial monitor on the Arduino. Each line, from the left, shows: ADDR bus in binary; DATA bus in binary, ADDR bus in hex; state of RWB pin; DATA bus in hex. The comments I've added later.
Code:
1111111111111100 00000000 fffc r 00
1111111111111101 10000000 fffd r 80
1000000000000000 10101001 8000 r a9 ; lda #$ff
1000000000000001 11111111 8001 r ff
1000000000000010 10001101 8002 r 8d ; sta $6002
1000000000000011 00000010 8003 r 02
1000000000000100 01100000 8004 r 60
0110000000000010 00000000 6002 W 00 ; so why is it writing 0??
1000000000000101 10101001 8005 r a9 ; lda #$e0
1000000000000110 11100000 8006 r e0
1000000000000111 10001101 8007 r 8d ; sta $6003
1000000000001000 00000011 8008 r 03
1000000000001001 01100000 8009 r 60
0110000000000011 00000000 6003 W 00 ; writing 0 again!
1000000000001010 10101001 800a r a9 ; lda #$38
1000000000001011 00111000 800b r 38
1000000000001100 10001101 800c r 8d ; sta $6000
1000000000001101 00000000 800d r 00
1000000000001110 01100000 800e r 60
0110000000000000 00000000 6000 W 00 ; yup, 0 again
There's a lot more of this sort of thing, but the result of every call to STA is 0 on the data bus. The 'r' and 'W' flags show that the RWB pin is in the correct state. And the opcodes and operands in the EEPROM are being loaded on to the data bus okay. Also, the PC appears to be operating normally, in that the addresses increment as you'd expect. I just don't understand why the 6502 appears not to be putting anything onto the data bus in write mode.
The machine is being run at 1Hz (yup, that slow) with a Rigol function gen as a clock source.
As a check, I reflashed the EEPROM with the code that had previously been working fine. With nothing having changed in the code, it too is now seeing only 0 on all writes.
I swear I've changed nothing other than the display (I tried removing that, too). Of course, this being a breadboard system, it's entirely possible I've accidentally nudged something.
I plan to hook up the scope to start checking signal levels where I can. But any ideas what sort of thing might cause this problem would be welcome.
_________________
I like it when things smoke.
Blog –
Zolatron 64 project