2018-02-19 01:58 PM
Hello guys.
I've started working with stm32f217zg series and i have a problem with external interupt.
I have programmed the mcu and after i push the button the interupt occurs two times instead of one.
I use cube mx to generate the code.
I attached the code so you can see it.
2018-02-20 12:26 AM
Being no friend of Cube, I don't browse through megabytes of autogenerated code.
But I suspect you configured an EXTI interrupt on both transitions (HL and LH), thus two interrupts.
For push buttons, I would use only the interrupt applying to the release event.
2018-02-20 01:19 AM
You do realise that mechanical switch contacts bounce - don't you?
See:
2018-02-20 01:51 PM
AvaTar wrote:
But I suspect you configured an EXTI interrupt on both transitions (HL and LH), thus two interrupts.
For push buttons, I would use only the interrupt applying to the release event.
I've set it for just falling edge.
2018-02-20 01:55 PM
Andrew Neil wrote:
You do realise that mechanical switch contacts bounce - don't you?
See:
https://community.st.com/0D50X00009XkXPNSA3
I've put a 500 ms delay after the interrupt occurs.This delay should fix this matter,doesn't it?
2018-02-20 02:53 PM
Does it fix the problem?
2018-02-20 04:24 PM
https://www.embedded.fm/blog/2016/11/10/discovery-debouncing
Article for you
Andrei
2018-02-21 12:41 AM
The bounce depends on the mechanical design. I came across switches that exhibited no bounce at all.
But for a normal sized button, 500ms is too much IMHO, one could do multiple presses during this time period.
I found 30 .. 50ms more appreopriate in my applications.
2018-02-21 02:34 AM
,
,
http://www.ganssle.com/debouncing.htm
, ,https://en.wikipedia.org/wiki/Switch ♯ Contact_bounce
,2018-02-21 03:29 AM
Thank you guys.Yeah the problem was the bounce of the push button i used.
I put that delay after all the codes in the EXTI interrupt routine so when i used push button the bounce make the interrupt happens again.I just needed to put a 30 ms before clearing the exti flag clears.