interrupt occurs one time only ..?? WHY

Discussion in 'Embedded Systems and Microcontrollers' started by Ahmed Adel, Nov 30, 2009.

  1. Ahmed Adel

    Thread Starter Member

    May 12, 2008
    18
    0
    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:

    Code ( (Unknown Language)):
    1.  
    2. ORG    0x00
    3.         goto start
    4.         org 0x04
    5.         goto myint
    6.  
    7.         RETFIE  
    8. myint
    9.        
    10.        
    11.         bsf PORTB,7
    12.         call delay
    13.        
    14.         bcf PORTB,7
    15.        
    16.         bcf INTCON,1
    17.  
    plz help
     
  2. AlexR

    Well-Known Member

    Jan 16, 2008
    735
    54
    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.
     
  3. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    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.
     
  4. Chaabane

    Member

    Nov 30, 2009
    37
    0
    I would use this way

     
  5. Ahmed Adel

    Thread Starter Member

    May 12, 2008
    18
    0
    thanks all ..
    sepcial thank to AlexR .. i think this was the catch of my problem .. I liked this board too much ..!!
     
Loading...