How identify the pin interrupted on GPIO Grouped Handler?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How identify the pin interrupted on GPIO Grouped Handler?

942 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Witte on Thu Sep 11 07:57:05 MST 2014
Hey there,

I'm using the GPIO Grouped Handler to watch 2 pins in "Or Mode". But when the interrupt occurs, I don't know which of the two pins set the interrupt. How can I know that?

I'm using a LPC4337 and the GPIO Group 1 Interrupt;

Follow my simple code (Main_CoreM0):

#define TEST_BUTTON_PORT            0
#define TEST_BUTTON_BIT             7
#define TEST_BUTTON_PIN_PORT        2
#define TEST_BUTTON_PIN_BIT         7
#define TEST_BUTTON_MODE_FUNC       SCU_MODE_FUNC0
#define TEST_BUTTON2_PORT            5
#define TEST_BUTTON2_BIT             2
#define TEST_BUTTON2_PIN_PORT        2
#define TEST_BUTTON2_PIN_BIT         2
#define TEST_BUTTON2_MODE_FUNC       SCU_MODE_FUNC4

void GINT1_IRQHandler(void)
{
Chip_GPIOGP_ClearIntStatus(LPC_GPIOGROUP, 1);
Board_LED_Toggle(0);
}

int main()
{
  Chip_SCU_PinMuxSet(TEST_BUTTON_PIN_PORT, TEST_BUTTON_PIN_BIT,
                                     (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | TEST_BUTTON_MODE_FUNC) );
  Chip_SCU_PinMuxSet(TEST_BUTTON2_PIN_PORT, TEST_BUTTON2_PIN_BIT,
                                     (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | TEST_BUTTON2_MODE_FUNC) );

  Chip_GPIO_SetPinDIRInput(LPC_GPIO_PORT, TEST_BUTTON_PORT, TEST_BUTTON_BIT);
  Chip_GPIOGP_SelectLowLevel(LPC_GPIOGROUP, 1, TEST_BUTTON_PORT, 1 << TEST_BUTTON_BIT);
  Chip_GPIOGP_EnableGroupPins(LPC_GPIOGROUP, 1, TEST_BUTTON_PORT, 1 << TEST_BUTTON_BIT);
  
  Chip_GPIO_SetPinDIRInput(LPC_GPIO_PORT, TEST_BUTTON2_PORT, TEST_BUTTON2_BIT);
  Chip_GPIOGP_SelectLowLevel(LPC_GPIOGROUP, 1, TEST_BUTTON2_PORT, 1 << TEST_BUTTON2_BIT);
  Chip_GPIOGP_EnableGroupPins(LPC_GPIOGROUP, 1, TEST_BUTTON2_PORT, 1 << TEST_BUTTON2_BIT);
  
  Chip_GPIOGP_SelectOrMode(LPC_GPIOGROUP, 1);
  Chip_GPIOGP_SelectEdgeMode(LPC_GPIOGROUP, 1);

  /* Enable Group GPIO interrupt 0 */
  NVIC_EnableIRQ(GINT1_IRQn);
 
  while(1)
  {
    __no_operation();
  }
}


Thanks!
Labels (1)
0 Kudos
8 Replies

812 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Witte on Mon Sep 15 14:46:23 MST 2014
Hey Starblue,

I will try use this... Thanks for your tip =)
0 Kudos

812 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by starblue on Fri Sep 12 06:18:52 MST 2014

Quote: Witte
How can I use the SCT like a PINT?



You can use SCT inputs to trigger events, which in turn can trigger an interrupt and capture a timer value. So it is rather different and more complex than using PINT, and you are limited to pins which can be used as SCT inputs. But on the positive side it can give you very precise times, down to the clock cycle.

Jürgen
0 Kudos

812 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Witte on Fri Sep 12 06:06:38 MST 2014
Not yet Jürgen,

How can I use the SCT like a PINT?
0 Kudos

812 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by starblue on Fri Sep 12 01:26:50 MST 2014

Quote: Witte
This will be a problem for me, because I will need to know the exactly time.



Have you considered using the SCT?

Jürgen
0 Kudos

812 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Witte on Thu Sep 11 12:17:37 MST 2014
No problem Nerd Herd =)

This will be a problem for me, because I will need to know the exactly time.

I saw in NVIC of CORE_M4, there are 8 interrupts "PINTx_IRQn" sources, but in the CORE_M0 just have the PINT4_IRQn. Do you know why?
Can I share, transfer or create an another PINT1_IRQn, for example, to the CORE_M0 (Like with PINT4_IRQn)?

Thanks!
0 Kudos

812 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by nerd herd on Thu Sep 11 11:52:45 MST 2014
Hi Witte,

Sorry for the confusion. It seems the Group GPIO Interrupt does not have a way implemented to check where the interrupt source came from. The best you can do is do a crude sampling of the enabled pins and check which ones were triggered. If you want to know the exact source, you will have to use the pin interrupts like I mentioned.
0 Kudos

812 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Witte on Thu Sep 11 10:33:42 MST 2014
Thanks for your reply Nerd Herd,

but I want to know about the Group GPIO Interrupt not the Pin Interrupt.
In this case, the two interrupts are directed to the same function Handler, and I don't know which PIN set the interrupt.
0 Kudos

812 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by nerd herd on Thu Sep 11 10:06:42 MST 2014
Hi Witte,

There is a pin interrupt status register that if read, can tell you which pins are currently requesting an interrupt. For more information, check out section 18.5.1.10 of the user's manual.

Link to LPC43xx user's manual:
http://www.lpcware.com/content/nxpfile/um10503-lpc43xx-user-manual
0 Kudos