The embedded system in question is the PIC 16F877 and I’m trying to increment the PORTC register with incfsz but it remains at 0. The tutorial says this is possible but I can’t get it to work.
list p=16f877
include "p16f877.inc"
__CONFIG _CP_OFF & _CPD_OFF & _LVP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_OFF & _XT_OSC
org 0x000 ; Start at the reset vector
nop ; Reserved for ICD in debu mode
Init
banksel PORTC
clrf PORTC ; Clear PORTC initially
; Set up the Timer0 control register
banksel OPTION_REG
movlw B'10000111' ; Internal clock, prescaler assigned to Timer0
movwf OPTION_REG ; prescaler, 1:256
clrf TRISC ; PORTC all output
banksel PORTC ; Back to Bank 0
movlw B'00000000'
Main
; Timer0 delay for acquisition
btfss INTCON,T0IF ; Loop until T0IF = 1 (TMR0 rollover)
goto Main
bcf INTCON,T0IF
incfsz PORTC , F
goto Main
LoopWhilePushed ; Loop if PORTB<0> = 0 (pressed)
btfss PORTB,0
goto LoopWhilePushed
goto Main ; Do it again
end
As a novice I cant do that, so I gave up on PORTC and defined a constant, incremented that and moved that WORKING regsiter into portc and got the same results. Yep Im a quitter.
UPDATE: As it turns out this it was subtle a hardware error that allowed all of the other experiments to function but prevent this one from working. It was not discovered until the circuit was rewired out of spite.