This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

About interrupt , can't run into the interrupt which number id is bigger than five!

the keil can detect the interrupt ,but can't run into the interrupt function !
thank you !

//my program ! use DS89C420 MICRO CHIP!

#include "reg420.h"
unsigned int count;
void ini_INT12(void);
main()
{
ini_INT12();

while(1);

}

void ini_INT12(void)
{
EX2 =1 ;
EA = 1;
}


void INT12(void) interrupt 12 using 2
{
P3 = 0; //can't run to here !
}

thank you !

Parents
  • Jeny, if you still need know why, here you go:


    "...
    - the keil can detect the interrupt, but can't run into the interrupt function !

    - Are you sure that the correct interrupt number is 12?

    - yes i can make sure ! because the keil set the interrupt flag EX3 to 1.

    - I think you are confusing the interrupt enable bits with the interrupt
    flags. You also seem to be confusing external interrupts 2 and 3.
    I still think you are specifying the wrong interrupt number for your
    interrupt service routine. I suggest you look at the Keil manuals and
    the datasheet for your device..."


    1. EX2 (or EX3, if you like) is not any interrupt flag but the
    interrupt enable bit!

    It was set by your program statement "EX2 = 1;", not by
    keil (debugger intervention)!

    IE2 (or IE3) in SFR EXIF (not bitaddressable register) is
    the correspondent interrupt flag.

    IE2 flag is set by processor (and keil debugger) when the following
    interrupt condition occurs:

    P1.4: 0->1 transition

    (for IE3 - P1.5: 1->0 transition)

    and must be cleared by software.

    2. As you know, when an interrupt is detected the processor control is
    directed at the correspondent fixed address (even if there is no service
    routine placed there!) in order the request to be serviced.

    For the external interrupts 2 and 3 these address vectors are 0x43(=67)
    and 0x4B(=75), respectively. Particular interrupts are assigned numbers
    according their addr. vectors in ascending order.
    Interrupt vectors make series:

    0x03(=3), 0x0B(=11), 0x13(=19), 0x1B(=27), and so on.

    That's why the relation between interrupt vector and interrupt number is:

    Int_vector = 3 + 8 * Int_number
    or
    Int_number = (Int_vector - 3) / 8

    Therefore the interrupt number for the external interrupt 2 is:

    (67 - 3)/8 = 8

    (for ext int.3 it is 9) and not 12!

    (Datasheet says 12 is the Watchdog interrupt number)

    So, I am sorry Jeny, but Stefan is definitely right.

    You can try the fixed program below:
    a) build the project
    b) run debugger
    c) open peripheral windows:
    I/O-Ports: Port1, Port2 and Port3
    (Interrupt System, select P1.4/Int2 or P1.5/Int3 sources) - not necessary
    d) run program (F5)
    e) clear and set repeatedly Port1 pins 4 and 5

    P1.4 0->1 transition will clear Port2 and set Port3
    P1.5 1->0 transition will clear Port3 and set Port2

    Good luck!


    #include "reg420.h"
    
    void ini_INT(void);
    
    void main(void)
    {
      ini_INT();
      while(1);
    }
    
    void ini_INT(void)
    {
      EX2 = 1;  // enable ext. interrupt 2: POSITIVE edge on P1.4
      EX3 = 1;  // enable ext. interrupt 3: NEGATIVE edge on P1.5
      EA = 1;
    }
    
    void INT8_EX2(void) interrupt 8
    {
      P2 = 0;         // you can certainly get here !
      P3 = 0xFF;
      EXIF &= ~0x10;  // clear external interrupt 2 request flag
    }
    
    void INT9_EX3(void) interrupt 9
    {
      P3 = 0;         // and here, too !
      P2 = 0xFF;
      EXIF &= ~0x20;  // clear external interrupt 3 request flag
    }
    

Reply
  • Jeny, if you still need know why, here you go:


    "...
    - the keil can detect the interrupt, but can't run into the interrupt function !

    - Are you sure that the correct interrupt number is 12?

    - yes i can make sure ! because the keil set the interrupt flag EX3 to 1.

    - I think you are confusing the interrupt enable bits with the interrupt
    flags. You also seem to be confusing external interrupts 2 and 3.
    I still think you are specifying the wrong interrupt number for your
    interrupt service routine. I suggest you look at the Keil manuals and
    the datasheet for your device..."


    1. EX2 (or EX3, if you like) is not any interrupt flag but the
    interrupt enable bit!

    It was set by your program statement "EX2 = 1;", not by
    keil (debugger intervention)!

    IE2 (or IE3) in SFR EXIF (not bitaddressable register) is
    the correspondent interrupt flag.

    IE2 flag is set by processor (and keil debugger) when the following
    interrupt condition occurs:

    P1.4: 0->1 transition

    (for IE3 - P1.5: 1->0 transition)

    and must be cleared by software.

    2. As you know, when an interrupt is detected the processor control is
    directed at the correspondent fixed address (even if there is no service
    routine placed there!) in order the request to be serviced.

    For the external interrupts 2 and 3 these address vectors are 0x43(=67)
    and 0x4B(=75), respectively. Particular interrupts are assigned numbers
    according their addr. vectors in ascending order.
    Interrupt vectors make series:

    0x03(=3), 0x0B(=11), 0x13(=19), 0x1B(=27), and so on.

    That's why the relation between interrupt vector and interrupt number is:

    Int_vector = 3 + 8 * Int_number
    or
    Int_number = (Int_vector - 3) / 8

    Therefore the interrupt number for the external interrupt 2 is:

    (67 - 3)/8 = 8

    (for ext int.3 it is 9) and not 12!

    (Datasheet says 12 is the Watchdog interrupt number)

    So, I am sorry Jeny, but Stefan is definitely right.

    You can try the fixed program below:
    a) build the project
    b) run debugger
    c) open peripheral windows:
    I/O-Ports: Port1, Port2 and Port3
    (Interrupt System, select P1.4/Int2 or P1.5/Int3 sources) - not necessary
    d) run program (F5)
    e) clear and set repeatedly Port1 pins 4 and 5

    P1.4 0->1 transition will clear Port2 and set Port3
    P1.5 1->0 transition will clear Port3 and set Port2

    Good luck!


    #include "reg420.h"
    
    void ini_INT(void);
    
    void main(void)
    {
      ini_INT();
      while(1);
    }
    
    void ini_INT(void)
    {
      EX2 = 1;  // enable ext. interrupt 2: POSITIVE edge on P1.4
      EX3 = 1;  // enable ext. interrupt 3: NEGATIVE edge on P1.5
      EA = 1;
    }
    
    void INT8_EX2(void) interrupt 8
    {
      P2 = 0;         // you can certainly get here !
      P3 = 0xFF;
      EXIF &= ~0x10;  // clear external interrupt 2 request flag
    }
    
    void INT9_EX3(void) interrupt 9
    {
      P3 = 0;         // and here, too !
      P2 = 0xFF;
      EXIF &= ~0x20;  // clear external interrupt 3 request flag
    }
    

Children
No data