cancel
Showing results for 
Search instead for 
Did you mean: 

Is there any way to distinguish EXTI interrupt about its edge?

Yang Yang
Associate II

Hello, ST experts

 

STM32F407 is used on our system. PE7 is configured as an EXTI pin for both rising and falling edge. How can I accurately  recognize which edge is the cause of this interrupt? Because there maybe a narrow glitch on PE7, so reading GPIO state on interrupt routine may not be a good way.

 

Best Regards

Yang

1 ACCEPTED SOLUTION

Accepted Solutions

If it's really important to catch a glitch, maybe have two EXTIs - one rising, and one falling?

 


@Yang Yang wrote:

Rising edge means pre-shutdown, falling edge means shutdown(at least 3 seconds interval). 


In this case, you know that the rising edge has to happen first - so set EXTI just for that.

Once that rising edge has occurred, then start your timing for the 3-second interval...

basically a debounce operation...

 

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

View solution in original post

6 REPLIES 6
Andrew Neil
Super User

@Yang Yang wrote:

Because there maybe a narrow glitch on PE7, so reading GPIO state on interrupt routine may not be a good way.


In that case, why does it matter which edge actually caused the interrupt?

Anyhow, it would have been the first edge - surely?

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

Hello,Andrew

 

Yes,it does matter which edge caused the interrupt. Different edges means different operations. Rising edge means pre-shutdown, falling edge means shutdown(at least 3 seconds interval).

By the way, think about this situation. Rising edge interrupt happened at 0 nano-second, but PE7 only keeps about 50 nano second, that means it goes low at 50 nano-seconds later. And interrupt routine clear the interrupt at about 1000 nano seconds later, is the falling edge interrupt ignored?

 

BR

Yang 

Ozone
Principal

Usually by checking the line status in the interrupt routine.

In case of a glitch, as Andrew Neil suggested, you are most probably too late anyway.
And the timing is unpredictable.

If this is a problem for your application, add a glitch filter. 
This is usually a RC lowpass with a Schmitt trigger 

If it's really important to catch a glitch, maybe have two EXTIs - one rising, and one falling?

 


@Yang Yang wrote:

Rising edge means pre-shutdown, falling edge means shutdown(at least 3 seconds interval). 


In this case, you know that the rising edge has to happen first - so set EXTI just for that.

Once that rising edge has occurred, then start your timing for the 3-second interval...

basically a debounce operation...

 

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

Hello, Ozone

 

I am very apprecaited for your help. I will have a try about your suggestion. And as I said, the falling edge will be ignored at that situation?(falling edge happened after interrupt routine clears pending register)

 

BR

Yang

I don't know your exact use case.
But you need to take system behavior in all plausible scenarios into account.
What happens if the second transition of a glitch happens before you even enter the interrupt (12 clk-cycle latency), or during the interrupt ?

Are those glitches of any relevance for your application, except of being an "annoyance" ?

As an example, all commercial ECUs we use have fixed or configurable glitch filters on DINs, defaulting to a 3dB frequency of a few kHz. Since our applications are based on a 10ms processing cycle, faster transitions/reactions are neither possible nor desired.
Other interfaces (like PWM or rotary encoders) are handled by specific peripherals, not software directly.

We have some self-designed legacy hardware designed in-house, which cause nothing but trouble in this regard.