cancel
Showing results for 
Search instead for 
Did you mean: 

EXTI on PortA (PA1 & PA2) Interrupt routine

daviddavid98
Associate II
Posted on September 09, 2010 at 14:18

EXTI on PortA (PA1 & PA2) Interrupt routine

4 REPLIES 4
brazov22
Associate II
daviddavid98
Associate II
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.

dhutchison1945
Associate II
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.

daviddavid98
Associate II
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