Michael Cartwright
Published © MIT

6502 SBC prototype - testing PCB rev 1.0

How do you test and fix your first PCB rev? What did I learn from the experience of moving perfboard prototype to a PCB?

IntermediateShowcase (no instructions)3 days211
6502 SBC prototype - testing PCB rev 1.0

Things used in this project

Hardware components

65C02
×1
MC6850
×1
65C22 VIA
×1
PCBWay Custom PCB
PCBWay Custom PCB
×1

Software apps and online services

Arduino IDE
Arduino IDE
PuTTY console
PrusaSlicer
Fusion 360
Autodesk Fusion 360
VASM

Hand tools and fabrication machines

SDS1104X-E (100 MHz) Oscilloscope

Story

Read more

Schematics

6502 Main Board - Rev 1.0

I'm including this for reference. It is the modified version that does not include the mistakes I made but it is also revision 1 .. there will be another ..

Code

65C02 Blink

Assembly x86
Minimal blink implementation to test that the 6522 VIA is working
; 65C22 VIA
PORTB = $F0
PORTA = $F1
DDRB  = $F2
DDRA  = $F3

  .org $8000  ; physical ROM starts at $8000
  .org $A000  ; addressable ROM starts at $A000

; Tests the VIA (built-in LED)
; - does not use RAM
; - does not use Timer
; - obviously requires RAM
;
; 1 mHz clock: A = 2 should give ~600ms delay
; 4 mHz clock: A = 6 should give ~500ms delay
;
testLEDOnly:
  lda #%11111111
  sta DDRA ; LCD: set all pins on port A to output


fastLoop: ; for slow clock
  smb7 PORTA ; turn the built-in LED on
  lda #%00000000
  rmb7 PORTA ; turn the built-in LED off
  bra fastLoop

nextLoop:
  smb7 PORTA ; turn the built-in LED on
  
  lda  #6     ; inner loop is ~330,000 cycles so this would be A x 330,000
  ldy  #255   ; (2 cycles)
  ldx  #255   ; (2 cycles)
delayLoopOn:
  dex          ; (2 cycles)
  bne  delayLoopOn   ; (3 cycles in loop, 2 cycles at end)
  dey          ; (2 cycles)
  bne  delayLoopOn   ; (3 cycles in loop, 2 cycles at end) 
  dec
  bne  delayLoopOn   ; (3 cycles in loop, 2 cycles at end) 
  
  rmb7 PORTA ; turn the built-in LED off
  
  lda  #6     ; inner loop is ~330,000 cycles so this would be A x 330,000
  ldy  #255   ; (2 cycles)
  ldx  #255   ; (2 cycles)
delayLoopOff:
  dex          ; (2 cycles)
  bne  delayLoopOff   ; (3 cycles in loop, 2 cycles at end)
  dey          ; (2 cycles)
  bne  delayLoopOff   ; (3 cycles in loop, 2 cycles at end) 
  dec
  bne  delayLoopOff   ; (3 cycles in loop, 2 cycles at end) 

  bra nextLoop

irq:
  rti

nmi:
  rti


; Reset/IRQ vectors
  .org $fffa
  .word nmi
  .word testLEDOnly
  .word irq
  
  
; http://forum.6502.org/viewtopic.php?p=62581#p62581
  ; delay 9*(256*A+Y)+8 cycles
  ; assumes that the BCS does not cross a page boundary
  ; A and Y are the high and low bytes (respectively) of a 16-bit value; multiply that 16-bit value by 9, then add 8 and you get the cycle count
  ;
  ; Note: I didn't bother counting the jsr and rts in the delay time for now.
  ;
  ;            1Mhz Clock     800Hz Clock
  ;            A      Y       A     Y
  ; 500ms      217    43      0     43
  ;  50ms      21    178      0     4
  ; 4.5ms       1    243      0     0
  ; 150us       0     16      0     0
  ;  
  ;  delayLoop:
  ;  cpy #1        ; 2
  ;  dey           ; 2
  ;  sbc #0        ; 2
  ;  bcs delayLoop ; 3
  

NOPs in a loop

Assembly x86
Minimal NOP test to make the CPU run in circles so we can observe success by counting in binary on the address lines.
  .org $8000  ; physical ROM starts at $8000
  .org $A000  ; addressable ROM starts at $A000

start:
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    bra start

irq:
  rti

nmi:
  rti


; Reset/IRQ vectors
  .org $fffa
  .word nmi
  .word start
  .word irq
  
  

RAM test using subroutine call

Assembly x86
Minimal code to call and return from subroutine to prove that writing to RAM (the stack for the return value) is working.
  .org $8000  ; physical ROM starts at $8000
  .org $A000  ; addressable ROM starts at $A000

start:
  jsr stackTest
  bra start
    
stackTest:
  rts

irq:
  rti

nmi:
  rti


; Reset/IRQ vectors
  .org $fffa
  .word nmi
  .word start
  .word irq
  
  

Credits

Michael Cartwright

Michael Cartwright

21 projects • 14 followers
Thanks to Ben Eater.

Comments