binary counter for 16f874a not working

Status
Not open for further replies.

henrock

New Member
PORTA equ 005h ;Port A Data Register
PORTB equ 006h ;Port B Data Register
TIMER equ 020h ;Spare register for delay
STATUS equ 003h
TRISA equ 085h
ADCON1 equ 09Fh

inres equ b'00000000' ;'Reset' input button SW0
inrun equ b'00000001' ;'Run' input button SW1

bcf STATUS,RP0
bcf STATUS,RP1 ;Selects Bank 0
clrf PORTA ; clears port A
bsf STATUS,RP0 ;Selects Bank 1
movlw 006h
movwf ADCON1
movlw b'00000'
movwf TRISA ;Prepares port A for Output
bcf STATUS,RP0
bcf STATUS,RP1 ;Selects Bank 0
clrf PORTA

movlw b'00000' ;Port A Data Direction Code
TRIS PORTA ;Load the DDR code into F86

goto reset

delay movwf TIMER ;is loaded into spare register

down decfsz TIMER ;decrement timer register
goto down ;and repeat until zero then
return ;return to main program

reset clrf PORTA ;Clear Port A Data

start btfsc PORTB,inres ;Test SW0 input button
goto reset ;and reset Port A

btfss PORTB,inrun ;Test SW1 input button
goto start ;and run count if pressed

incf PORTA ;Increment count at Port A
movlw 002 ;Delay count literal
call delay ;Execute delay subroutine
goto start ;Repeat main loop

end ;Terminate source code
 
Whoever's teaching you this stuff should be using include files as has been the norm for the past decade. I don't see any pushbutton debounce code.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…