I've been struggling for the past few days trying to get this to work right and need a professional to take a look at this and see where I am going wrong:
Code:
; James
; 5/8/24
; Global Vars
TrisA equ 0x85
TrisB equ 0x86
Status equ 0x03
PortA equ 0x05; This bit is the register, so PortA is not used in Setup.
PortB equ 0x06
;Setup+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
BSF Status, 0x05; Bit 5 points to bank 1
Movlw 0x0f; moves 0000 1111 into W reg
Movwf TrisA; Moves W to TrisA, Port A is input
Movlw 0x00; moves 0000 0000 into W reg
Movwf TrisB; Moves W to TrisB, Port B is output
BCF Status, 0x05; Bit 5 points back to bank 0
;Run======================================================================
START clrf PortB; clears PortB
clrf PortA; clears PortA
Movf PortA,0; Moves inputs to W reg
Movwf PortB; Moves W reg to outputs
Call Delay
Goto START
Delay Movlw 0X08; moves 0000 1000 to Reg W, sets 8ms timer
MOVWF 0X0C; Moves Reg W to Reg C
Dec DECFSZ 0X0C,1; Decrements Reg C by 1 ms
goto Dec; will keep looping until Reg C hits 0, timer ends
Return
end
Lab reqs:
- Using a slow clock or delay loops, develop a program that will output in 4 bit binary code the input of 4 switches.
- The program, once started should continue to run and scan or search the input switches until the power is removed.
I would like to note that the code I am using here was provided as-is from my professor, however, either an element in the code or design just gives me a dead circuit.

