Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Can you provide us the connection of the input pin (GP3)?still not working
start
bsf GPIO,1 ;set GP1 high
;LED on GP1 should be on.
check btfss GPIO,3 ; if SW still pressed dont clr led
bcf GPIO,5 ;turn off LED
btfss GPIO,3 ;test GP3 if button on computer was pressed
goto check ;if not then return to check again
bsf GPIO,5 ;turn on LED
goto check ;do it all again
end
same result as before.
Should gP3 be floating? I already tried vdd with 10k
list p=12f629 ; list directive to define processor
#include <p12f629.inc> ; processor specific variable definitions
errorlevel -302 ; suppress message 302 from list file
__CONFIG _CP_OFF & _CPD_OFF & _BODEN_OFF & _MCLRE_ON & _WDT_OFF & _PWRTE_ON & _INTRC_OSC_NOCLKOUT
;***** VARIABLE DEFINITIONS
w_temp EQU 0x20 ; variable used for context saving
status_temp EQU 0x21 ; variable used for context saving
d1 EQU 0x40
d2 EQU 0x41
d3 EQU 0x42
d5 EQU 0x43
d6 EQU 0x44
d7 EQU 0x45
;**********************************************************************
ORG 0x000 ; processor reset vector
goto main ; go to beginning of program
ORG 0x004 ; interrupt vector location
movwf w_temp ; save off current W register contents
movf STATUS,w ; move status register into W register
movwf status_temp ; save off contents of STATUS register
movf status_temp,w ; retrieve copy of STATUS register
movwf STATUS ; restore pre-isr STATUS register contents
swapf w_temp,f
swapf w_temp,w ; restore pre-isr W register contents
retfie ; return from interrupt
main
bsf STATUS,RP0 ; set file register bank to 1
call 0x3FF ; retrieve factory calibration value
movwf OSCCAL ; update register with factory cal value
bcf STATUS,RP0
clrf GPIO
;GPIO port setup
movlw 07h ;set GP0,GP1 and GP2
movwf CMCON ;turn comparator off
bsf STATUS,RP0 ;set file register to bank 1
movlw 08h ;move literal(value) 1C in hex or 00001000 in binary to working register.
movwf TRISIO ;move literal(value) in working register to TRISIO making GP3 as input(default)
;and leaving GP0,GP1,GP2,GP4 and GP5 as outputs.
bcf STATUS,RP0 ;set file register bank to 0
start
nop
nop
nop
bsf GPIO,1 ;set GP1 high
;LED on GP1 should be on.
;to confirm that microprocessor has setup all ports to input and outputs.
goto check
check
bcf GPIO,5 ;turn off LED
call Delay2
bsf GPIO,5
call Delay
flash bcf GPIO,1 ;infinite loop
call Delay
bsf GPIO,1
call Delay
goto flash
Delay
;999990 cycles
movlw 0x07
movwf d1
movlw 0x2F
movwf d2
movlw 0x03
movwf d3
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay_0
;6 cycles
goto $+1
goto $+1
goto $+1
;4 cycles (including call)
return
Delay2
;59999994 cycles
movlw 0x23
movwf d5
movlw 0xCB
movwf d6
movlw 0x83
movwf d7
Delay2_0
decfsz d5, f
goto $+2
decfsz d6, f
goto $+2
decfsz d7, f
goto Delay2_0
;2 cycles
goto $+1
;4 cycles (including call)
return
END ; directive 'end of program'
If you have it connected to VDD and when pressed its grounded then shouldn't it be "btfsc" ?GP3 should be connected to Vdd via a 10k (any) resistor.
Mike.
start
bsf GPIO,1 ;set GP1 high
;LED on GP1 should be on.
check
btfsc GPIO,3 ; if SW still pressed dont clr led
bcf GPIO,5 ;turn off LED
btfsc GPIO,3 ;test GP3 if button on computer was pressed
goto check ;if not then return to check again
bsf GPIO,5 ;turn on LED
goto check ;do it all again
end