Hi I’m doing a small project in PIC16F628A.I’m in the final part. I have got stuck in here.
This is how it works. When power up the two segments showing “00”.
At this time if I press the button the separate RA4 LED should turn ON while the two segments also must show the “00”
But here I can see only the segments showing “00” I cannot see the RA4 LED is ON.
(Here is the code, I have limit the code for easy view)
I have use a pull-up resistor in RA4. Some times I can see the led lights up very dim mode. The value 470ohms.
Can somebody tell me what’s the mistake in my code?
Thanks a lot
This is how it works. When power up the two segments showing “00”.
At this time if I press the button the separate RA4 LED should turn ON while the two segments also must show the “00”
But here I can see only the segments showing “00” I cannot see the RA4 LED is ON.
(Here is the code, I have limit the code for easy view)
Code:
;FLAG2,0= button press flag bit
;FLAG2,1= counter ON flag bit
;LoopCount=50
;COUNTER = 5 (COUNTER has set to 5 seconds)
;DISPLAY THE TWO DIGITS
CLFLAG2 bcf FLAG2,0 ;clear the button press flag bit
MULTIPLEX bcf PORTA,1
movf SEGMANT1,0
call TABLEP
movwf PORTB
bsf PORTA,0 ;display digit1
call DEL10ms
bcf PORTA,0
movf SEGMANT2,0
call TABLEP
movwf PORTB
bsf PORTA,1 ;display digit2
call DEL10ms
;COUNTER PART
btfss FLAG2,1 ;is counter running?
goto CHECKBUTTON1 ;no, do other stuff
bsf PORTA,4 ;yes, turn ON the output
decfsz LoopCount,1 ;count 50 times round loop
goto MULTIPLEX ;50*20mS = 1 second(total delay 20ms in multiplex mode)
movlw .50
movwf LoopCount
decfsz COUNTER,1
goto MULTIPLEX
bcf FLAG2,1 ;stop counter
bcf PORTA,4 ;turn OFF the output after 5 seconds
goto BEGIN
;check the button is pressed
CHECKBUTTON1 btfsc PORTA,3 ;test the set button(RA3)
goto CHECKBUTTON2
call DEL0.9ms ;debounce delay
bsf FLAG2,1 ;enable the counter
CHECKBUTTON2 btfsc PORTA,2 ;test the count up button (RA2)
goto CLFLAG2
countupstuff
Can somebody tell me what’s the mistake in my code?
Thanks a lot