6522 doesn't register input
Posted: Sun Oct 26, 2025 10:12 pm
Good afternoon!
I've finally gotten back to building 6502 SBCs. I've run into an issue that is boggling my mind. I've been trying to fix it for two weeks and I've been losing sleep.
My current design uses a WDC 6522 to bit-bang SPI to a MAX3100 UART. I've had this working without issue in the past. I'm thinking the problem must be really simple and I'm overlooking something incredibly obvious.
Using port A, I've set bit 0 to SCLK, bit 1 to MISO, bit 2 to CS, and bit 7 to MOSI. I have absolutely no problem sending the write configuration bytes, and I can send text to my PC. Apparently I have the baud rate set correctly. The issue is I can't read anything. Bit 7 is ALWAYS 0. I've scoped it and the 3100 sets the bit to 1, and I can probe that 1 at the 6522, but no matter what I do it doesn't show up when I read port A.
I've re-wired it to use port B, no dice. I wrote my transmit routine to wait until the transmit buffer is empty (indicated by the second bit returned when sending any command, I'm using read config 0, 1), but since the transmit buffer empty is indicated with a 1, it never leaves the loop. If I run it with a slow clock (approx 600Hz) and leave out the buffer empty check it transmits fine, but I can't receive anything either.
I've also hooked the 3100 to an arduino and it works without issue. I made certain that the DDR was set correctly by setting it every call to the buffer empty check, even though I'm sure it wasn't changed from initialization. I set the DDR to %01111111, marking bit 7 as input.
I also switched it to bit 6 and used bvc but I got the same result. I'm at a loss. My SBC is on a PCB, so I can't wire in a DIP 6522 (I'm using a PLCC), but I can't imagine the chip is bad - everything else seems to work. Also I didn't need that BIT instruction before. The inc instruction was enough to set the negative flag.
I also just tried manually using an LED to follow an input pin:
I can flash the LED by writing to it directly, but it won't follow the input. I used LDA instead of BIT too.
Hopefully this post wasn't too scatterbrained. My migraine isn't helping. If you have any ideas, please let me know! The oscilloscope shows signals that make complete sense. I"m positive the 3100 is working. I've read the datasheet and I tried setting the ACR so latching is disabled, and I've disabled IRQs just in case they could've been an issue, both on the 6522 and the 3100. I want to implement a Rx IRQ but that's pointless right now.
I'm going to go take some Tylenol. I hope everyone is well!
Steve
I've finally gotten back to building 6502 SBCs. I've run into an issue that is boggling my mind. I've been trying to fix it for two weeks and I've been losing sleep.
My current design uses a WDC 6522 to bit-bang SPI to a MAX3100 UART. I've had this working without issue in the past. I'm thinking the problem must be really simple and I'm overlooking something incredibly obvious.
Using port A, I've set bit 0 to SCLK, bit 1 to MISO, bit 2 to CS, and bit 7 to MOSI. I have absolutely no problem sending the write configuration bytes, and I can send text to my PC. Apparently I have the baud rate set correctly. The issue is I can't read anything. Bit 7 is ALWAYS 0. I've scoped it and the 3100 sets the bit to 1, and I can probe that 1 at the 6522, but no matter what I do it doesn't show up when I read port A.
I've re-wired it to use port B, no dice. I wrote my transmit routine to wait until the transmit buffer is empty (indicated by the second bit returned when sending any command, I'm using read config 0, 1), but since the transmit buffer empty is indicated with a 1, it never leaves the loop. If I run it with a slow clock (approx 600Hz) and leave out the buffer empty check it transmits fine, but I can't receive anything either.
I've also hooked the 3100 to an arduino and it works without issue. I made certain that the DDR was set correctly by setting it every call to the buffer empty check, even though I'm sure it wasn't changed from initialization. I set the DDR to %01111111, marking bit 7 as input.
Code: Select all
SPI_transmitempty: ; returns 1 if transmit buffer is empty
phy
lda #%00111111 ; XXX DEBUG: make certain pin 7 is an input
sta DDRA ; XXX
ldy #MISO ; bit 1 high
stz PORTA ; 0 SPI_start
inc PORTA
dec PORTA ; first bit is receive buffer empty bit - don't care
sty PORTA ; 1 (Read Config)
inc PORTA ; Transmit buffer bit should be at pin 7 MISO
bit PORTA
bpl .90 ; if T is 0 (pin 7 is 0) go to .90
; It's not getting here for some reason..
lda #$01
;bra .91
.90:
;lda #1 ; DEBUG
;.91:
dec PORTA ; Accumulator should now be zero or one. Finish operation.
ldy #CS
sty PORTA ; SPI_end
ply
rts
I also just tried manually using an LED to follow an input pin:
Code: Select all
reset:
ldx #$FF
txs
lda #$FF
sta DDRB
lda #$7F
sta DDRA
ldx #1
stz PORTB
test:
bit PORTA
bpl t1
stz PORTB
bra t2
t1:
stx PORTB
t2:
jmp test
Hopefully this post wasn't too scatterbrained. My migraine isn't helping. If you have any ideas, please let me know! The oscilloscope shows signals that make complete sense. I"m positive the 3100 is working. I've read the datasheet and I tried setting the ACR so latching is disabled, and I've disabled IRQs just in case they could've been an issue, both on the 6522 and the 3100. I want to implement a Rx IRQ but that's pointless right now.
I'm going to go take some Tylenol. I hope everyone is well!
Steve