littletransistor
New Member
Hey there,
I'm now learning how to use the ports as the inputs, and I bumped into a small problem there, the switch is not working. The switch, when I hold it, it's permenantly on, and when I release it, it's off. Just a simple one.
Here's the code: (I took some of them from the PICKit II tutorials since I have the training board)
The push-button switch is RA3. I have accessed the TRISC, put them all to ones, but it's still not working the way it should.
I'm now learning how to use the ports as the inputs, and I bumped into a small problem there, the switch is not working. The switch, when I hold it, it's permenantly on, and when I release it, it's off. Just a simple one.
Here's the code: (I took some of them from the PICKit II tutorials since I have the training board)
Code:
#include <p16F690.inc>
__config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _BOR_OFF & _IESO_OFF & _FCMEN_OFF)
org 0x00
cblock 0x20
count1
count2
count3
display
endc
bsf STATUS,RP0
movwf b'11111111'
movwf TRISA
clrf TRISC
movlw b'00000000'
movwf TRISC
bcf STATUS,RP0
bsf STATUS,RP1
movlw 0xF7
movwf ANSEL
bcf STATUS,RP0
bcf STATUS,RP1
movlw 0x01
movwf display
Start:
btfss PORTA,3
call TurnOnLED
goto Start
TurnOnLED:
movlw b'00001111'
movwf PORTC
Delay
movlw D'3'
movwf count3
movlw D'138'
movwf count2
movlw D'86'
movwf count1
Delay_0
decfsz count1,1
goto $-1
decfsz count2,1
goto $-3
decfsz count3,1
goto $-5
retlw 0
end
The push-button switch is RA3. I have accessed the TRISC, put them all to ones, but it's still not working the way it should.