interrupt occurs one time only ..?? WHY

Thread Starter

Ahmed Adel

Joined May 12, 2008
18
dear everybody ..

I have an interrupt that occurs one time only and doesn't repeat also I have cleared bit1 in INTCON register, bits 4 and 7 of INTCON are also set using bsf .. I want a led to flash once external interrupt (RB0/INT) is triggered .. this is my interrupt subroutine:

Rich (BB code):
ORG    0x00
        goto start
        org 0x04
        goto myint

        RETFIE  
myint
        
        
        bsf PORTB,7
        call delay
        
        bcf PORTB,7
        
        bcf INTCON,1
plz help
 

AlexR

Joined Jan 16, 2008
732
You are not returning from the interrupt!
The RETFIE should either go at the end myint code or you should do a CALL of the myint routine rather than a GOTO. With the the GOTO in its present position the RETFIE will never get executed.
 

Markd77

Joined Sep 7, 2009
2,806
My suggestion would be to get rid of the goto and move the code to before the RETFIE (which re-enables interrupts but as Alberto says does not clear them).
You could instead put the RETFIE after the quoted code but it would not appear be useful here.
Also worth noting that big delays while interrupts are disabled could cause you to miss further interrupts and that in most cases some code is needed in the interrupt to save and restore the W register, STATUS and PCLATH. This code is found in the datasheets in the interrupt section.
 

Chaabane

Joined Nov 30, 2009
37
I would use this way

ORG 0x00
goto start

ORG 0x004

bcf INTCON,INTE ;disable RB0 interrupt (optional,but good habit )
bsf PORTB,7
call delay
bcf PORTB,7
bcf INTCON,INTF ;erase RB0 flag
bsf INTCON,INTE ;enable interrupt
RETFIE ;return from interrupt and set GIE (INTCON) ON
 
Top