Skip to main content
Visitor II
September 9, 2010
Question

EXTI on PortA (PA1 & PA2) Interrupt routine

  • September 9, 2010
  • 4 replies
  • 1140 views
Posted on September 09, 2010 at 14:18

EXTI on PortA (PA1 & PA2) Interrupt routine

    This topic has been closed for replies.

    4 replies

    Visitor II
    May 17, 2011
    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 15:10

    Hi,

    i already checked this example.

    i do not understand how i can filter the source pin which initiated the interrupt.

    the interrupt routine says:

    {

      if ((GPIO_ReadInputData(JOYSTICK_PORT) & JOYSTICK_LEFT_PIN) == 0x00)

      {

        GPIO_WriteReverse(LEDS_PORT, LED1_PIN);

      }

      if ((GPIO_ReadInputData(JOYSTICK_PORT) & JOYSTICK_RIGHT_PIN) == 0x00)

      {

        GPIO_WriteReverse(LEDS_PORT, LED2_PIN);

      }

      if ((GPIO_ReadInputData(JOYSTICK_PORT) & JOYSTICK_UP_PIN) == 0x00)

      {

        GPIO_WriteReverse(LEDS_PORT, LED3_PIN);

      }

      if ((GPIO_ReadInputData(JOYSTICK_PORT) & JOYSTICK_DOWN_PIN) == 0x00)

      {

        GPIO_WriteReverse(LEDS_PORT, LED4_PIN);

      }  

    }

    ....

    ReadInputData reads the complete port value, but i want to detect on 2 pins of the same port rising and falling edges independently.

    for example: in my routine if one of the pins goes high (the other is low) it fires my interrupt routine and then i check with ReadInpuData the value. But if the other is high and the pin goes high, it will perform two actions if i would do something with ReadInputData and this ''if''-structure.

    Now i'm using PortB for my second input to get really different interrupt sources which i can handle.

    But i think there should be a more convenient way to do this only with one port.

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 15:10

    you need to do an xor on the port x register at every interrupt in order to discriminate the interrupt source.

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 15:10

    Hi,

    that sounds easy, but which register xor with what?

    i can't find a register which gives me the information in the manual!

    thanks