Ducados
Junior Member level 1
pic16f690 setup ports
I'm having a problem programming the 16f690, I need 2 inputs on porta and only RA1 is behaving correctly. The problem occurs if I configure RA2 or any other pin as input. The pin senses input OK, but keeps sensing input for another 2 or 3 seconds, in other words it doesn't stop sensing input when the input is removed.
I've tried various configurations with ANSEL, ANSELH and CM1CON0.
I'm just trying to move a motor back and forward depending on the input.
Here's a code example, If anyone can help I'll sure be grateful.
bsf STATUS,5
movlw 00h
movwf 87h
bcf STATUS,5
; SETUP PORTS A AND B TO INPUT
bsf STATUS,5
movlw 0xFF
movwf TRISA ; Make PortA all input
movlw 0xFF
movwf TRISB ; Make PortB all input
banksel ANSEL
movlw h'0'
movwf ANSEL
movlw h'0'
movwf ANSELH
bcf STATUS,5
loop
btfsc PORTA,1
goto bwd
btfsc PORTA,2
goto fwd
goto loop
fwd:
movlw b'000001' ; GO FORWARD
movwf 07h
goto loop
bwd:
movlw b'000100' ; GO BACKWARD
movwf 07h
goto loop
I'm having a problem programming the 16f690, I need 2 inputs on porta and only RA1 is behaving correctly. The problem occurs if I configure RA2 or any other pin as input. The pin senses input OK, but keeps sensing input for another 2 or 3 seconds, in other words it doesn't stop sensing input when the input is removed.
I've tried various configurations with ANSEL, ANSELH and CM1CON0.
I'm just trying to move a motor back and forward depending on the input.
Here's a code example, If anyone can help I'll sure be grateful.
bsf STATUS,5
movlw 00h
movwf 87h
bcf STATUS,5
; SETUP PORTS A AND B TO INPUT
bsf STATUS,5
movlw 0xFF
movwf TRISA ; Make PortA all input
movlw 0xFF
movwf TRISB ; Make PortB all input
banksel ANSEL
movlw h'0'
movwf ANSEL
movlw h'0'
movwf ANSELH
bcf STATUS,5
loop
btfsc PORTA,1
goto bwd
btfsc PORTA,2
goto fwd
goto loop
fwd:
movlw b'000001' ; GO FORWARD
movwf 07h
goto loop
bwd:
movlw b'000100' ; GO BACKWARD
movwf 07h
goto loop