Reply
Posts: 185
Registered: ‎10-03-2015

Clearing Interrupts

There is probably probably a simple solution to the below. Still learning...

 

I have a pin configured as an interrupt. It is a constant pulsing input between 10 and 400Hz. 

 

The input is enabled and then disabled for short periods of time to do some measurements. Even when the interrupt is disabled, there is activity on the pin. To enable the interrupt I use:

 

 

GPIO_IntClear(1<<7);
GPIO_IntEnable(1<<7);

 

To disable the interrupt when it is no longer needed I use:

 

 

 

GPIO_IntDisable(1<<7);
GPIO_IntClear(1<<7);

 

THE ISSUE:

 

With the above approach the interrupt flag is still set for the input even after I clear the flag and disable the interrupt.  This is an issue when another input interrupt is triggered and I can't tell what the actual source was.

 

THE QUESTION

 

What is the proper way to disable a pin so that the interrupt flag will not get set? GPIO_ExtIntConfig does not seem to work here either. Do I have change the pin mode?

 

Posts: 113
Registered: ‎07-12-2016

Re: Clearing Interrupts

hi Superpanda

 

In fact, we can find some example code about the gpio interrupt, for example AN0012.

http://www.silabs.com/products/mcu/Pages/32-bit-mcu-application-notes.aspx

 

And I also did a simple experiment to enable/disable the gpio interrupt base on AN0012 with EFM32TG, enable the PD8 interrupt with GPIO_IntConfig(gpioPortD, 8, false, true, true); and disable the interrupt in the ISR with GPIO_IntConfig(gpioPortD, 8, false, true, false); After disable the interrupt no any interrupt will be observed.

 

Thanks

Highlighted
Posts: 185
Registered: ‎10-03-2015

Re: Clearing Interrupts

I did follow AN0012 as well. The interrupt can in fact be disabled as you observed, however...

 

Even with the interrupt disabled the interrupt flag is getting set when there is activity on the pin so when another interrupt from a different pin fires and I read the interrupts to clear, the disabled interrupt's flag is set. Odd.

 

I built a work-around in the mean time, but I still think I am either not doing something proper or not understanding the behavior. 

<a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Star</font></font> </a> ju
Posts: 4
Registered: ‎03-02-2017

Re: Clearing Interrupts

I have the same problem...

Have you fin a solution?

Posts: 185
Registered: ‎10-03-2015

Re: Clearing Interrupts

No, I did not. I just kluged it for now. 

Posts: 2,810
Registered: ‎02-07-2002

Re: Clearing Interrupts

Since the source of the interrupt flag happened the flag should be set. Just as you see. And since the interrupt was disabled it should not trigger the interrupt as it doesn't. But when another enabled source triggers the interrupt you see this flag and what you should do is AND it with the enable register to mask off disabled sources.
Posts: 185
Registered: ‎10-03-2015

Re: Clearing Interrupts

Ok,thanks. That is essentially what I was doing before thinking it was not normal, but indeed now it does seem the appropriate way to do it. In fact, I just noticed an emlib function that sums up what I was doing.

 

GPIO_IntGetEnable()