[PN7462AU] GPIO interrupt

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

[PN7462AU] GPIO interrupt

Jump to solution
3,611 Views
autoever1leka
Contributor I

Good day,

 

I'm a engineer using PN7462AU. I am developing an NFC communication program. 

My question is very similar to this question. But there's no answer on that page.

※ URL : PN7462 GPIO Interrupts 

I want to use GPIO as an interrupt source. When I receive the GPIO signal, I want to call the callback function.

There are API about GPIO. But I can't find API about setting GPIO callback function.

Question 1) Is there an API to set GPIO callback function?

 - For example, using GPIO1, how to setting dwPcrIRQMessage?

 - Should I use phhalPcr_RegCallBack ()?


Question 2) How to use GPIO as an interrupt source?

Below is the setup details,

1. Hardware: PN7462AU
2. SDK: PN7462AU-FW_v05.21.00
3. IDE: MCUXpresso IDE v11.0.0

If anyone knows the answer to your question, please reply.

If you have any question, please feel free to contact me.

 

Thanks.

Labels (1)
0 Kudos
Reply
1 Solution
3,419 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Haje,

Actually it is more likely an implementation issue , you may check some flag in the ISR to determine whether the callback should be invoked, and the flag is initialized from start up and modified by the application code in some cases.

BTW, why keeping GPIO high all the time? You may disable the pull up in the ISR or callback.

Hope that makes sense,

Have a great day,
Kan


-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

View solution in original post

0 Kudos
Reply
11 Replies
3,419 Views
autoever1leka
Contributor I

Hi Kan,

The reason I always give the GPIO High is just for testing.

When the test is over, the callback function will be called only at the rising edge, and thanks to Kan, it was successfully completed.

In the previous question, even if the GPIO signal is low, the callback function is still called. As the cause is known, the GPIO clear API did not work properly.

I used another GPIO clear API and it worked fine.

So my GPIO interrupt related questions have been solved.

I sincerely thank you for helping me.

Have a great day.

Haje.

0 Kudos
Reply
3,419 Views
Kan_Li
NXP TechSupport
NXP TechSupport

My pleasure:-)

Have a great day,
Kan


-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
Reply
3,419 Views
autoever1leka
Contributor I

Dear Kan

Hi Kan, I read your answer carefully, but I have a few more questions, so I leave additional questions.

It's about question 1.

I want to use GPIO01 as an interrupt source.

① I set the GPIO01 like below.

 - phhalPcr_ConfigUnput(1, true, false, true, false, true, false);

 - API input parameter 4th, it means EnableInterrupt. So I set true.

 - phhalPcr_ConfigPuPd(1, true, false);

 - Pull up setting.

② I set callback function like below.

 - phhalPcr_RegCallBack(&CallbackFunction, PcrIrqMessage);

 - void CallbackFunction(void) {

      printf("CHECK\n"); // Callback function just prints message.

   }

 - PcrIrqMessage = {PCR_INT_STATUS_REG_GPIO1_PAD_HIGH_INT_STATUS_MASK

                                 | PCR_INT_STATUS_REG_GPIO_INT_STATUS_MASK);

I set the GPIO01 as interrupt source as above. But even if I give GPIO01 signal high in my program, It cannot recognize GPIO01 interrupt.

What's wrong with the above source code? (I think the PcrIrqMessage setting is wrong, but I'm not sure.)

If you have any question, please feel free to contact me. 

Thanks.

0 Kudos
Reply
3,419 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Haje,

Did you test it based on PN7462EVB? and maybe there is a typo here, it should be "phhalPcr_ConfigInput" , not "phhalPcr_ConfigUnput". and where did you put these codes? There is default setup for GPIOs from start up in the library, so please put your initial code in main().

Have a great day,
Kan


-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
Reply
3,419 Views
autoever1leka
Contributor I

Dear Kan

Thank you for answering the question. There was a typo in the process of posting a question, but in my code, I used it correctly as "phhalPcr_ConfigInput". The GPIO setting part is located in the main().

 - PcrIrqMessage = {PCR_INT_STATUS_REG_GPIO1_PAD_HIGH_INT_STATUS_MASK

                                 | PCR_INT_STATUS_REG_GPIO_INT_STATUS_MASK);

Is it correct to set up PCR to use GPIO1?

If you have any question, please feel free to contact me. 

Thanks.

0 Kudos
Reply
3,419 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Haje,

Your code is ok, and if you just want to GPIO1 as interrupt source, no need to use phhalPcr_RegCallBack(), which is used for register callback for GPIO common ISR, you may just define the GPIO1 ISR as below :

pastedImage_1.png

and put the initial code as below:

pastedImage_2.png

if you set a breakpoint in the ISR, you may find it hits as expected.

pastedImage_3.png

Hope that makes sense,

Have a great day,
Kan


-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
Reply
3,419 Views
autoever1leka
Contributor I

Dear Kan

 

Thanks to you, I could recognize GPIO01 high signal using the method just define the GPIO1 ISR.

However, I still have one more question.

In my program, the callback function is always called when GPIO01 is high.

Even if GPIO01 changes to low, the callback function is executed continuously.

I want to call the callback function only once when GPIO goes high.

If I put phhal_Nvic_DisableInterrupt (1U << (PHHAL_NVIC_GPIO_01_Isr)) into GPIO_01_IRQHandler(), it is called only once, but IRQHandler is not called when GPIO goes high again after that.

So I put phhal_Nvic_EnableInterrupt (1U << (PHHAL_NVIC_GPIO_01_Isr)) into GPIO_01_IRQHandler(), then IRQHandler is continuously executed when GPIO is high.

Question) Is there a way to call the callback function only once when GPIO goes high?

If you have any question, please feel free to contact me. 

Thanks.

0 Kudos
Reply
3,419 Views
s_ali
Contributor III

Hi Haje,

I had the similar issue where the interrupt was firing continuously even when configured for edge triggered. The following in the ISR fixed the issue for me (I believe that the earlier instructions were not actually clearing the correct Interrupt flag):

#define TEK_I2C_DATA_PIN    1

#define PHHAL_GPIO_PCR_INT_GPIO_POS     15

void GPIO_01_IRQHandler(void)
{

    PH_REG_SET_BITN_WO(PCR_INT_CLR_STATUS_REG, PHHAL_GPIO_PCR_INT_GPIO_POS + TEK_I2C_DATA_PIN);
    phHal_Nvic_ClearPendingInterrupt( 1U << (PHHAL_NVIC_GPIO_Common_Isr + TEK_I2C_DATA_PIN));

...

}

I copied the interrupt clearing instructions from the function "phhalPcr_ConfigInput()":

pastedImage_1.png

and this was my configuration for the pin:

pastedImage_2.png

I would say that NXP documentation is None or too Complicated for a functionality which is far too simple and basic.

0 Kudos
Reply
3,419 Views
autoever1leka
Contributor I

Dear Shoaib Ali

Thank you very much for answering my question. Since I did the above, it did not work properly, and I found that the cause is that GPIO Clear is not working properly. That is, the GPIO Clear API provided by NXP did not work properly, and it was solved by implementing it by directly changing the register value.

In the method I implemented, GPIO Clear was performed directly with PH_REG_SET_BIT_WO (PH_INT_CLR_STATUS_REG, GPIOX_PAD_HIGH_INT_CLR_STATUS).

Thank you for answering again. Have a good day.

0 Kudos
Reply
3,420 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Haje,

Actually it is more likely an implementation issue , you may check some flag in the ISR to determine whether the callback should be invoked, and the flag is initialized from start up and modified by the application code in some cases.

BTW, why keeping GPIO high all the time? You may disable the pull up in the ISR or callback.

Hope that makes sense,

Have a great day,
Kan


-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
Reply
3,419 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Haje,

The GPIO interrupt sources from PCR, so you should use PCR APIs.

pastedImage_2.png

Question 1) Is there an API to set GPIO callback function?

 - For example, using GPIO1, how to setting dwPcrIRQMessage?

 - Should I use phhalPcr_RegCallBack ()?

pastedImage_1.png


Question 2) How to use GPIO as an interrupt source?

pastedImage_3.png

Hope that makes sense,

Have a great day,
Kan


-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
Reply