hello guyz how r u all?
i need ur help with this problem , am using the external interrupt of pic16f876a
as i know that after the interrupt finished it should return to the same location its occurred but in my code i don't want to return it back to the same location i want it to goto another location .
so i tested my code it works but the interrupt happened just once !!When i power up the circuit so what is the problem ? i cleared the interrupt flag but still there is a problem
PLZ HELP
i need ur help with this problem , am using the external interrupt of pic16f876a
as i know that after the interrupt finished it should return to the same location its occurred but in my code i don't want to return it back to the same location i want it to goto another location .
so i tested my code it works but the interrupt happened just once !!When i power up the circuit so what is the problem ? i cleared the interrupt flag but still there is a problem
Code:
;//interrupt code
;///////////////////////////////
TMR0 EQU 1
PORTA EQU 5
PORTB EQU 6
PORTC EQU 7
TRISA EQU 5
TRISB EQU 6
PORTC EQU 7
TRISC EQU 7
PC EQU 2
STATUS EQU 3
ZEROBIT EQU 2
CARRY EQU 0
EEADR EQU 0DH
EEDATA EQU 0CH
EECON1 EQU 0CH
EECON2 EQU 0DH
ADCON1 EQU 1FH
RD EQU 0
WR EQU 1
WREN EQU 2
ADCON0 EQU 1FH
ADCON1 EQU 1FH
ADRES EQU 1EH
CHS0 EQU 3
GODONE EQU 2
INTCON EQU 0BH
OPTION_R Equ 1
GIE EQU 7 ;global Interrupt bit
INTE EQU 4 ;B0 interrupt enable bit.
INTF EQU 1 ;B0 interrupt flag
COUNT EQU 24H ;means count is file 0C.
;a register to count events.
TMR0_T EQU 20H ;TMR0 temporary file
W_TEMP EQU 21H ;W temporary file
STATUS_T EQU 22H ;STATUS temporary file
PORTB_T EQU 23H ;PORTB temporary file
COUNT_T EQU 25H
;******************************************
LIST P=16F876A
ORG 0
GOTO START
ORG 4
GOTO ISR ;location4 jumps to ISR
;************************************************
;SUBROUTINE SECTION
; DELAY FOR 1 SEC
DELAY CLRF TMR0
MOVLW .61
MOVWF COUNT
BCF STATUS,5
WAITA BCF INTCON,2
WAITB BTFSS INTCON,2
GOTO WAITB
DECFSZ COUNT,1
GOTO WAITA
RETURN
RETLW 0
;Interrupt Service Routine
ISR
MOVWF W_TEMP ;Save W
MOVF STATUS,W
MOVWF STATUS_T ;Save STATUS
MOVF TMR0,W
MOVWF TMR0_T ;save TMR0
MOVF COUNT,W
MOVWF COUNT_T ;save PORTB
BSF PORTC,7
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
BCF PORTC,7
BSF INTCON,GIE
BCF INTCON,INTF ;Reset Interrupt Flag
COMP MOVF STATUS_T,W
MOVWF STATUS ;Restore Status
MOVF TMR0_T,W
MOVWF TMR0 ;Restore TMR0
MOVF COUNT_T,W
MOVWF COUNT ;Restore PORTB
MOVF W_TEMP,W ;Restore W
GOTO ss ;Return from the interrupt
;**************************************************************
;CONFIGURATION SECTION
START BCF STATUS,5 ; BANK0
BCF STATUS,6
CLRF PORTA
CLRF PORTB
CLRF PORTC
BSF STATUS,5 ; BANK1
MOVLW 0X06
MOVWF ADCON1
MOVLW B'00011111'; PORTA are I/P
MOVWF TRISA
MOVLW B'00000001' ;B0 is an input, B1-7 O/P
MOVWF TRISB
MOVLW B'00000000'
MOVWF TRISC
MOVLW B'01000101' ;Prescalar is /64
MOVWF OPTION_R
BCF STATUS,5
CLRF PORTA ;Clears PortA.
CLRF PORTB ;Clears PortB.
BSF INTCON,GIE ;Enable Global Interrupt
BSF INTCON,INTE ;Enable B0 interrupt
;***********************************************************
;program starts now
BEGIN BSF PORTC,7
CALL DELAY
BCF PORTC,7
CALL DELAY
GOTO BEGIN
ss
BSF PORTC,1
CALL DELAY
CALL DELAY
CALL DELAY
BCF PORTC,1
GOTO BEGIN
END
PLZ HELP