LPC55S69: how-to detect both edges for more than one GPIO pin by GINT0/1

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

LPC55S69: how-to detect both edges for more than one GPIO pin by GINT0/1

2,122 Views
EugeneHiihtaja
Senior Contributor I

Hello !

 

I need to have ISR by multiple GPIO lines in ACTIVE, SLEEP and POWER DOWN modes.

I would like to detect both edges and try to utilize both GINTx and include pin twice and configure GINT0 for detect rising edge and GINT1 for falling edge ( or vise versa).

If only one pin added to both GINTx, both edges are detected. If more than 1, it start to detect falling edge only.

Weird. May be it depends from some configuration what should be used when power management API is called ?

I have checked all possible combinations and haven't find working combination how-to detect both edges for set of pins from both GPIO ports.

 

Is any limitations exists ? There are not visible in UM.

I have attached exact modified gint example.

 

Essential part :

 

/* Select one input, active low for GINT0 */
#define DEMO_GINT0_POL_MASK_LOW ~(1U << BOARD_SW1_GPIO_PIN)
#define DEMO_GINT0_POL_MASK_HIGH (1U << BOARD_SW1_GPIO_PIN)

#define DEMO_GINT0_ENA_MASK (1U << BOARD_SW1_GPIO_PIN)

 

/* Select two inputs, active low for GINT1. SW2 & SW3 must be connected to the same port */
#define DEMO_GINT1_POL_MASK_LOW ~((1U << BOARD_SW2_GPIO_PIN) | (1U << BOARD_SW3_GPIO_PIN))
#define DEMO_GINT1_POL_MASK_HIGH ((1U << BOARD_SW2_GPIO_PIN) | (1U << BOARD_SW3_GPIO_PIN))

#define DEMO_GINT1_ENA_MASK ((1U << BOARD_SW2_GPIO_PIN) | (1U << BOARD_SW3_GPIO_PIN))

#define DEMO_GINT1_SW2_POL_MASK_LOW    ~((1U << BOARD_SW2_GPIO_PIN))
#define DEMO_GINT1_SW2_POL_MASK_HIGH     ((1U << BOARD_SW2_GPIO_PIN))
#define DEMO_GINT1_SW2_ENA_MASK                ((1U << BOARD_SW2_GPIO_PIN))

#define DEMO_GINT1_SW3_POL_MASK_LOW     ~((1U << BOARD_SW3_GPIO_PIN))
#define DEMO_GINT1_SW3_POL_MASK_HIGH      ((1U << BOARD_SW3_GPIO_PIN))
#define DEMO_GINT1_SW3_ENA_MASK                ((1U << BOARD_SW3_GPIO_PIN))

 

....

 

/* Initialize GINT0 & GINT1 */
GINT_Init(GINT0);
GINT_Init(GINT1);

/* Setup GINT0 for edge trigger, "OR" mode */
GINT_SetCtrl(GINT0, kGINT_CombineOr, kGINT_TrigEdge, gint0_callback);

/* Setup GINT1 for edge trigger, "OR" mode */
GINT_SetCtrl(GINT1, kGINT_CombineOr, kGINT_TrigEdge, gint1_callback);


/* Select pins & polarity for GINT0 */

//GINT_ConfigPins(GINT0, DEMO_GINT0_PORT, DEMO_GINT0_POL_MASK_LOW, DEMO_GINT0_ENA_MASK); // GPIO0, pin 5, SW1
//GINT_ConfigPins(GINT0, DEMO_GINT0_PORT, DEMO_GINT0_POL_MASK_HIGH, DEMO_GINT0_ENA_MASK); // GPIO0, pin 5, SW1

GINT_ConfigPins(GINT0, DEMO_GINT1_PORT, DEMO_GINT1_POL_MASK_HIGH, DEMO_GINT1_ENA_MASK); //
//GINT_ConfigPins(GINT0, DEMO_GINT1_PORT, DEMO_GINT1_POL_MASK_LOW, DEMO_GINT1_ENA_MASK);

 


/* Select pins & polarity for GINT1 */
//GINT_ConfigPins(GINT1, DEMO_GINT0_PORT, DEMO_GINT0_POL_MASK_HIGH, DEMO_GINT0_ENA_MASK); // GPIO0, pin 5, SW1
//GINT_ConfigPins(GINT1, DEMO_GINT0_PORT, DEMO_GINT0_POL_MASK_LOW, DEMO_GINT0_ENA_MASK); // GPIO0, pin 5, SW1

GINT_ConfigPins(GINT1, DEMO_GINT1_PORT, DEMO_GINT1_POL_MASK_LOW, DEMO_GINT1_ENA_MASK); // Port1, pins 9, 18
//GINT_ConfigPins(GINT1, DEMO_GINT1_PORT, DEMO_GINT1_POL_MASK_HIGH, DEMO_GINT1_ENA_MASK); // Port1, pins 9, 18

 

 

/* Enable callbacks for GINT0 & GINT1 */
GINT_EnableCallback(GINT0);
GINT_EnableCallback(GINT1);

 

// This compination works, e.g bot edges detected for ISP pin and falling edges for SW2 and SW3 pins.

 GINT_ConfigPins(GINT0, DEMO_GINT0_PORT, DEMO_GINT0_POL_MASK_HIGH, DEMO_GINT0_ENA_MASK); // GPIO0, pin 5, SW1

GINT_ConfigPins(GINT1, DEMO_GINT0_PORT, DEMO_GINT0_POL_MASK_LOW, DEMO_GINT0_ENA_MASK); // GPIO0, pin 5, SW1

GINT_ConfigPins(GINT1, DEMO_GINT1_PORT, DEMO_GINT1_POL_MASK_LOW, DEMO_GINT1_ENA_MASK); // Port1, pins 9, 18

I mean if you have example for EVK where both edges are detected for all 3 buttons ( ISP, SW2 and SW3), it would be perfect answer.

 

Could you suggest how-to allocate multiple pins from GPIO1 port for be able to detect rising and falling edges

?

 

Regards,

Eugene

0 Kudos
18 Replies

1,786 Views
Alexis_A
NXP TechSupport
NXP TechSupport

Hello Eugene,

There's a pretty similar example to what you want to do in the SDK, it's called pint_pin_interrupt.

Let me know if this helps you.

Best Regards,

Alexis Andalon

0 Kudos

1,786 Views
EugeneHiihtaja
Senior Contributor I

Hi Alexis !

There are is not equal. GINTx can include multiple pins and they able to wakeup MCU from POWER DOWN low power mode.

I have 17 pins what should be able to do wakeup.

According spec, every GINTx can have up to 32 pins and do wakeup due falling or rising edges.

Can you expand gint example when all 3 buttons , due any edge can wakeup MCU from power down mode ?

Regards,

Eugene

0 Kudos

1,786 Views
Alexis_A
NXP TechSupport
NXP TechSupport

Hello Eugene,

 

As you mention, the PINT module only has  8 pins to wake up but unfortunately the GINT only can be configured as falling edge or rising edge, not both due to you can only select one polarity. The PINT has 8 ways to wake up the MCU but only in deep-sleep so if you will go to power-down is not an option. What you could do is to connect to two pins the same button and check different polarities but this will waste some pins.

 

But do you need that this pins to wake up with both edges? If you explain more about your project maybe I could suggest a solution for it.

 

Best Regards,

Alexis Andalon

0 Kudos

1,786 Views
EugeneHiihtaja
Senior Contributor I

Hi Alexis !

Yes we really need to use GINTx for be able to serve gpio interrupts in ACTIVE, SLEEP and POWER DOWN modes.

And I have 17 gpio pins what is able to generate rising or falling edges. And I should detect ( and wakeup) applicable edge for each pin.

10 pins from port1 generate falling edges always.

5 pins from port1 generate rising edges always.

1 pint from port 0 - generate both edges

1 pin from port 1 - generate both edges.

Let's check if I understand latest specification. And what is true and what is not.

1.

GINT0 can be programmed to detect rising edge.

GINT1 - falling edge

2. Any set of GPIO pins e.g from port0 and port1 can be included to any GPIOx.

  For example 5 pins from port0 and 5 pins from port 1 can be included to GINT0.

3. The same GPIO pins can be included to GINT1 detect other edge.

   So it is not a limitation when the same pin included to both GINTx. e,g twice.

What is not true in those assumptions ?

I can see if pin is configured as GPIO input pin, inversion is applicable as well.

If I include ISP pin  ( button ) to both GINTx,  both edges can be detected as expected.

But if it more than 1 pin - they start to  block each other and both edges or even any edge is not detected any more.

I think for prove situation, you can use EVK and detect both edges from 3 buttons what are available on board at the same time.

It should be possible if GINTx working according spec. Is this so ?

Or how GINTx should work and what are limitations ?

Regards,

Eugene

0 Kudos

1,786 Views
Alexis_A
NXP TechSupport
NXP TechSupport

 Hi Eugene,

Please check my answers bellow:

1. GINT0 can be programmed to detect rising edge. GINT1 - falling edge

Both ports can be configured for falling or rising but not both.

 

2. Any set of GPIO pins e.g from port0 and port1 can be included to any GPIOx. For example 5 pins from port0 and 5 pins from port 1 can be included to GINT0.

For example, if you want to use the PIO0_6 you will need to enable the bit 6 in the GINT0, each bit correspond to a pin.

 

3. The same GPIO pins can be included to GINT1 detect other edge. So it is not a limitation when the same pin included to both GINTx. e,g twice.

This conection need to be done physically, so for example if you want to wake up with both edges you will need to connect to a pin in the Port 0 and the Port 1, and one enable with the rising edge and other with the falling one.  

I found something strange with the documentation, with my test using the board I found the following behavior.

COMB : 1 | POL : 1 - Each pin trigger the interruption

COMB : 0 | POL : 0 - Each pin trigger the interruption

COMB : 0 | POL : 1 - Need to match all the pins to trigger the interruption

COMB : 1 | POL : 0 - Need to match all the pins to trigger the interruption

I already report this and I'll let you know when I receive some feedback.

Best Regards,

Alexis Andalon

0 Kudos

1,786 Views
EugeneHiihtaja
Senior Contributor I

Hi Alexis !

If both GINTx configured for detect edges :

/* Setup GINT0 for edge trigger, "OR" mode */
GINT_SetCtrl(GINT0, kGINT_CombineOr, kGINT_TrigEdge, gint0_callback);

/* Setup GINT1 for edge trigger, "OR" mode */
GINT_SetCtrl(GINT1, kGINT_CombineOr, kGINT_TrigEdge, gint1_callback);


/* Select pins & polarity for GINT0 */

// Rising edge e.g high detection
GINT_ConfigPins(GINT0, DEMO_GINT0_PORT, DEMO_GINT0_POL_MASK_HIGH, DEMO_GINT0_ENA_MASK); // GPIO0, pin 5, SW1

 /* Select pins & polarity for GINT1 */

// falling edge eg. low detection
GINT_ConfigPins(GINT1, DEMO_GINT0_PORT, DEMO_GINT0_POL_MASK_LOW, DEMO_GINT0_ENA_MASK); // GPIO0, pin 5, SW1

and one pin e.g PIO0_5  is included to configuration of both configurations, both edges are detected and I have gint0 and gint1 callbacks.

But if more that 1 pin is included to detect both edges, it dosn't work.

So you think that the same pin can't be part of GINT0 and GINT1 configurations ?

Is this so ?

So one pin can be used for detect one edge only ? It mean it should be included or to GINT0 when rising edge need to be detected

or to GINT1 if falling edge need to be detected. is this so ?

If I need to detect both edges from one pin, this pin should move from one gint to other one OR if it not possible, 2 physical pins need to be allocated

and one included to GINT0 and other one to GINT1 configuration, is this so ?

Each GINTx can include any amount of pins as from GPIO port 0 and from 1.

We need clear explanations of GINTx functionality . I have play with all of those rules and pins are masking each other and interrupt is missing.

Only one combination work fine all the time, if one GINTx is in use and all pins included there for detect falling edges.

Pin can be configured as GPIO pin and after that inversion can be applied, but it again have some weared effect and some pins are not generate interrupts any more.

I think I need to undestand how-to split pins between GINTx controllers if some pins require rising edge and other falling edge detection.

But for some pins both edges need to be detected  and may be the need physical dublication.

Please explain those rules becouse UM is not so informative yet.

Regards,

Eugene

0 Kudos

1,786 Views
Alexis_A
NXP TechSupport
NXP TechSupport

Hello Eugene,

 

I think I was not clear about the GINT functionality, for example, if you want to a single button, in my case I will use the S2 (WAKEUP) you will need to interconnect two pins, one from the GINT0 and one from the GINT1, the S2 button is at the PIO1_18 so you could also connect it to one from the GINT0, for example PIO0_18. So you will need the following configurations in the GINT registers:

 

GINT0_POL  = (1U << 18)

GINT0_COMB = 1

 

GINT1_POL =  ~(1U << 18)

GINT0_COMB = 0

 

Let me know if this helps you.

 

Best Regards,

Alexis Andalon

0 Kudos

1,786 Views
EugeneHiihtaja
Senior Contributor I

Hi Alexis !

This is what I talking about and it is the problem.

You can include any one pin to both GINTx and detect rising and falling edges as it expected if we read specification.

GINT_ConfigPins(GINT0, DEMO_GINT1_PORT, DEMO_GINT1_SW2_POL_MASK_HIGH, DEMO_GINT1_SW2_ENA_MASK); // Port1, pin 18, rise
GINT_ConfigPins(GINT1, DEMO_GINT1_PORT, DEMO_GINT1_SW2_POL_MASK_LOW, DEMO_GINT1_SW2_ENA_MASK); // SW2 only, fall

BUT !

Try to include in similar way on/two extra pin to to POL mask and to ENA mask.

On EVT board you have 2 different buttons and if LPC working according spec you should be able to get GINTx callback everytime when you press and release any button.

Could you try to use all 3 buttons on your side and see if both edges are detected.

Current assumption it is some silicon bug or controller works in different way e.g in case of multiple pins only falling edge is detected.

We need to finalise scheme but can't becouse GINTx controller is not working according spec or we don't have latest spec.

Regards,

Eugene

0 Kudos

1,786 Views
Alexis_A
NXP TechSupport
NXP TechSupport

Hi Eugene,

Please check the code example attached, you should connect the GPIO buttons to the following ones:

BUTTON GPIO               GPIO

PIO0_5                           PIO1_11

PIO1_18                         PIO0_18

PIO1_9                           PIO0_15

Best Regards,

Alexis Andalon

0 Kudos

1,786 Views
EugeneHiihtaja
Senior Contributor I

Hi Alexis !

Could you please and reattach example. It is not visible for me.

It means if I connect one input to 2 pins and GINT0 configured for rising edge and GINT1 for falling edge

it should work ?

Regards,

Eugene

0 Kudos

1,786 Views
Alexis_A
NXP TechSupport
NXP TechSupport

Hi Eugene,

That's right, for this I connect two GPIO one from the Port 1 and Port 0 to the same button. I will attach only the source code, you can replace it in the examples lpcxpresso55s69_gint.

0 Kudos

1,786 Views
EugeneHiihtaja
Senior Contributor I

Hi Alexis !

Thank you !

I will try tomorrow morning asap.

But can you give explanation how it different from specification.

At list pin can't be included to both controllers.

I can see rising edge pins are included to GINT0 what is initialized as kGINT_CombineAnd  not OR.

Also you suddently select only pins from gpio port 0 for this operation.

GINT_ConfigPins(GINT0, DEMO_GINT0_PORT, DEMO_GINT0_POL_MASK, DEMO_GINT0_ENA_MASK);

So in one GINTx controller I shouldn't mix pins from kGINT_Port0 and kGINT_Port1 ?

Please explain.

Regards,

Eugene

0 Kudos

1,786 Views
Alexis_A
NXP TechSupport
NXP TechSupport

Hi Eugene,

That's the strange thing with the documentation that I previously mention, depending of the polarity the COMB bit that correspond to the AND/OR operation need to change.

Please check the following configurations:

COMB : 1 | POL : 1 - OR

COMB : 0 | POL : 0 - OR

COMB : 0 | POL : 1 - AND

COMB : 1 | POL : 0 - AND

COMB = 1 = kGINT_CombineAnd .

COMB = 0 = kGINT_CombineOr

I already reported this issue to the applications team.

Best Regards,
Alexis Andalon

0 Kudos

1,786 Views
EugeneHiihtaja
Senior Contributor I

Hi Alexis !

Thank you !

Looks like it is really work like this and kGINT_CombineAnd  should be used for "collect" pins what required rising edge detection.

I have made few tests and looks like the same pin work fine if it included in both GINTx for be able to detect both edges.

Is any reason in this case if you recommend to use 2 physicals pins if both edges should be detected ?

Or this also some issue and it might work but really will be fixed in next silicon revision ?

Also I can see if pin inversion in use blocks edges detection and logic is not so clear as well.

GINTx has own connection to external pin and is any specified way known how-to pin inverting coexists with GINTx edge detection logic ?

Regards,

Eugene

0 Kudos

1,786 Views
Alexis_A
NXP TechSupport
NXP TechSupport

Hi Eugene,

Could you let me know which pins are you using and how are you configuring the module?

Best Regards,

Alexis Andalon

0 Kudos

1,786 Views
EugeneHiihtaja
Senior Contributor I

Hi Alexis !

I use bot controllers where one collect pins for fall edge detection and other one for rise edge ( AND ).

GINT_SetCtrl(GINT0, kGINT_CombineAnd, kGINT_TrigEdge, gint0_callback); // Rise edge
GINT_SetCtrl(GINT1, kGINT_CombineOr, kGINT_TrigEdge, gint1_callback);  // fall edge

But one edge detection happens , that line should be disabled. For example in case of falling edge and pin continue to have low state,

it continue to lock both controllers and any edge can't be detected any more.

I try to use GINTx pins for wakeup from PowerDown mode only and after that use PINTx ( 8 pin max ). But falling edge is not detected and low level detection can be used. But if MCU go to PowerMode once, PINTx controller dosn't work any more and any reinitialisation dosn't help.

So PowerDown mode have some effect for PINTx controller and it lock it forever and only reboot help.

So I still think how to detect rising and falling edges for 17 pins ( they all on GPIO PORT1) ( only one pin need both edges detection) and able to wakeup by all of them from PowerDown mode and do not miss any edge event.

Regards,

Eugene

0 Kudos

1,786 Views
Alexis_A
NXP TechSupport
NXP TechSupport

Hi Eugene,

As the reference manual mention in the Table 303. Parameter wakeup_interrupts, the GINT can be used to wake up from Power-Down but the PINT that will correspond to the WAKEUP_GPIO_INT0_x can't be used:

pastedImage_1.png

That's why I mention to use two physical pins if you want to wake up from Power-Down using both edges.

Best Regards,

Alexis Andalon

0 Kudos

1,786 Views
EugeneHiihtaja
Senior Contributor I

Hi nxf46116‌ !

Problem in other dimension. If one GINTx pin detects own edge and stay in new position it block both GINTx controllers.

And it not depends if it included or not to other GINTx.

It means if falling edge is happens  and pin continue to stay low, it is not possible to detect any other edges in any GINTx controller.

Press ISP button and keep it , try to press SW2 or 3 there are completely locked even there are connected to other controller.

If to the same gpio PINTx is attached and it configured for falling edge and GINTx wakeup MCU from PowerDown, that falling edge is not "translated " to PINTx.

So it create situation that to keep GiNTx for able to detect edges all the time in any mode, I should disable occured edge asap

and enabled back only when that pin returned back to original state. So it is useful for detect short pulses but for track all edges I should 

disable/enable certain pin all the time. As result it is possible to miss edges.

Regards,

Eugene

0 Kudos