Hi guys I made a 4 digit counter. If there is an input in the interrupt pin (RB0) it will increment the display one by one.
It’s working well. I want to know is my ISR ok or is it too long?
Because I want to count very speedy inputs when given to it.
Thanks
Here is the digits updating part within the ISR routine.
Here is the display multiplex stuff of 4 digits. It’s in the main routine.
It’s working well. I want to know is my ISR ok or is it too long?
Because I want to count very speedy inputs when given to it.
Thanks
Here is the digits updating part within the ISR routine.
Code:
org 0004h
movwf w_temp ;save W
movf STATUS,W
movwf status_temp ;save status
Zeroa incf Digit0,F ;increment digit0
movf Digit0,W
bcf STATUS,Z
xorlw .10
btfss STATUS,Z ;check digit0 has reached 10
goto Leave ;No then leave
clrf Digit0 ;YES clrf digit0 and-
bsf Dselect,1 ;set bit 1 in Digit select register
Onea incf Digit1,F ;increment digit1
movf Digit1,W
bcf STATUS,Z
xorlw .10
btfss STATUS,Z ;check digit1 has reached 10
goto Leave ;No then leave
clrf Digit1 ;YES clrf digit1 and-
bsf Dselect,2 ;set bit 2 in Digit select register
Twoa incf Digit2,F ;increment digit2
movf Digit2,W
bcf STATUS,Z
xorlw .10
btfss STATUS,Z ;check digit2 has reached 10
goto Leave ;NO then leave
clrf Digit2 ;YES clrf digit2 and-
bsf Dselect,3 ;set bit 3 in Digit select register
Threea incf Digit3,F ;increment digit3
movf Digit3,W
bcf STATUS,Z
xorlw .10
btfss STATUS,Z ;check digit3 has reached 10
goto Leave :NO then leave
clrf Digit3 ;YES clrf digit3 and-
clrf Dselect ;sclear the Digit select register
goto Leave
Leave movf status_temp,W
movwf STATUS
swapf w_temp,F
swapf w_temp,W
bcf INTCON,INTF ;clear the INTF to recieve more int.
retfie
Here is the display multiplex stuff of 4 digits. It’s in the main routine.
Code:
Mulpx clrf PORTB
clrf PORTA
btfsc Dselect,1 ;if Dselect bit = 1
call One ;Show only digit 0 & 1
btfsc Dselect,2 ;if Dselect bit = 2
call Two ;Show only digit 0 & 1 & 2
btfsc Dselect,3 ;if Dselect bit = 3
call Three ;Show only digit 0 & 1 & 2 & 3
btfss Dselect,0 ;if Dselect bit = 0
call Zero ;show only 0 digit
goto Mulpx
Three movlw b'00001000' ;enable digit3
movwf PORTA
movf Digit3,W
call Table
movwf PORTB
call Delay
Two movlw b'00000100' ;enable digit2
movwf PORTA
movf Digit2,W
call Table
movwf PORTB
call Delay
One movlw b'00000010' ;enable digit1
movwf PORTA
movf Digit1,W
call Table
movwf PORTB
call Delay
Zero movlw b'00000001' ;enable digit0
movwf PORTA
movf Digit0,W
call Table
movwf PORTB
call Delay
return