clearing interrupt status flag is not working

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

clearing interrupt status flag is not working

1,460 Views
danielebruno
Contributor III

Hello,

I'm using the KL26 microcontroller in one of our boards.

I have a problem about clearing pending flags / disabling / enabling interrupts.

I have configured one input on PORTC in order to generate an interrupt on its falling edge but there is a function that must not be interrupted by the signal above-mentioned:

void My_Function(void)
{

DisableIRQ(BOARD_DATA_IN_IRQ);

/*******************************/

Instructions executed by the function.....

/*******************************/

GPIO_PortClearInterruptFlags(BOARD_DATA_IN_GPIO, 1U << BOARD_DATA_IN_PIN);

EnableIRQ(BOARD_DATA_IN_IRQ);
}

The system doesn't work because as the pulse arrives, the function is interrupted.

There is something wrong in the sequence that I have written ?

Thank you for all the attention,

Best Regards

Daniele

Labels (1)
0 Kudos
3 Replies

1,321 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi DANIELE BRUNO ,

  Do you want to disable the Port interrupt?

  If yes, you need to use DisableIRQ(BOARD_DATA_IN_IRQ);, not just clear the flag.

  Clear flag, just disable the ongoing interrupt flag, not the next  port interrupt, that's why even you clear the flag, you still can enter the interrupt handler. So, you can try to use disableIRQ.

Wish it helps you!

If you still have questions about it, please kindly let me know.

Have a great day,
Kerry

 

-------------------------------------------------------------------------------
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

1,321 Views
danielebruno
Contributor III

Hi Kerry,

as you can see I use the DisableIRQ(BOARD_DATA_IN_IRQ) instruction when I enter in My_Function but it doesn't work.

Perhaps I have to introduce some delay or control between GPIO_PortClearInterruptFlags and EnableIRQ instructions ?

Have a great day,
Daniele

0 Kudos

1,321 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi DANIELE BRUNO,

   Yes, I know, you use the DisableIRQ(BOARD_DATA_IN_IRQ) instruction , but in your function, you enable it again:

void My_Function(void)
{

DisableIRQ(BOARD_DATA_IN_IRQ);

/*******************************/

Instructions executed by the function.....

/*******************************/

 

GPIO_PortClearInterruptFlags(BOARD_DATA_IN_GPIO, 1U << BOARD_DATA_IN_PIN);

 

EnableIRQ(BOARD_DATA_IN_IRQ);
}

So, you can comment EnableIRQ(BOARD_DATA_IN_IRQ); Then try it again, whether you still can enter the interrupt or not?

Wish it helps you!

If you still have questions about it, please kindly let me know.

Have a great day,
Kerry

 

-------------------------------------------------------------------------------
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