cancel
Showing results for 
Search instead for 
Did you mean: 

How to interrupt the STM32F4, with a pulse signal having a rising edge and after some ms followed by a falling edge.

Loni
Associate II

Hello,

I would like to know, whether it is possible to configure GPIO pins of STM32F4 MCU family to be interrupted by a pulse signal which has a rising edge and after 100ms followed by a falling edge, like in the screenshot attached. (something like high to low transition)

Is it possible for GPIO pins to be interrupted by the occurrence of both edges?

If so, how can be coded - any idea ?

I thank you for your time,

Loni

7 REPLIES 7
TDK
Guru

No, you can't have it interrupt on a pulse. Only rising and/or falling edges. You could use the timer to measure the pulse width and then do something based on that, but it'll take CPU resources at every edge.

If you feel a post has answered your question, please click "Accept as Solution".
Loni
Associate II

Thank you for your answer.

Best Regards,

Loni

RMcCa
Senior II

You could use the exti interrupt and change the edge polarity in the isr. ​

Loni
Associate II

Hello,

Thank you for your reply. Do you have any code of this ?

I am new in this community and lack some experience.

Could you tell me how to change the polarity inside the ISR, please.

Loni

Sorry no. From memory in my dealings with the F7, you need to set a sysconfig register and ​bits in the exti registers for the interrupt mask and edge polarity. You can change the edge polarity in the isr. RTM.

Loni
Associate II

Hello RMcCa

Thank you for your reply.

I have configured the interrupt using SYSCFG and EXTI for unmasking and selecting the trigger edge.

However, within ISR code, I am not sure what kind of code structure could do it.

Maybe:

A rising edge could trigger the ISR,

Then inside the ISR, the falling edge could be set and its status of occurrence has to be monitored with an IF-statement.

When the condition is met, the the rest of the code can start to execute...

Do you think will be valid ?

I thank you for your time,

Loni

Piranha
Chief II

You can use a timer in one pulse combined reset and trigger mode. Set external trigger to rising edge, input capture on falling edge and connect the pins together externally. Enable the input capture interrupt and check the captured value, which will represent the length of pulse. You can even filter out too long pulses with hardware by setting timer period to some 120 ms, for example.