2021-01-07 07:02 AM
I can make LEDs blink at different frequencies but only 1 frequency...
So far i managed to get the LED config going with CubeMX.
I want to make this by using External Interrupts.
But how can i make the same LED change frequency by pushing a button on my STM32F407VG?
I managed to make other LEDs light with interrupts, but the same? oh no :(
I would appreciate your help a lot ty:)
2021-01-07 07:09 AM
Homework?
> I want to make this by using External Interrupts.
EXTI is not suitable for pushbuttons. They produce many edges at push/release due to mechanical bouncing of contacts.
For homework, what's wrong with
while(1) {
LedToggle();
if (ButtonInput() == 0) {
Delay(LONG);
} else {
Delay(SHORT);
}
}
?
JW
2021-01-07 07:15 AM
Ye homework...
Thanks for the quick answer
Hm i guess that works.
But we are supposed to practice external inputs x(
2021-01-07 03:21 PM
You mean, external interrupts.
Yes, a typical school assignment. It's the wrong task, as I've said above. And, actually, should you genuinely need to handle a noisy signal in EXTI, it's actually quite hard to do correctly.
What you are expected to do is:
This will work, somehow.
Write the simple version I outlined above, without EXTI, first, and get it running.
Then try to write the interrupt version and debug it until it works somehow. If in trouble, try harder; if in serious trouble, ask.
If you want to go further and understand the problem which is in this approach, draw yourself waveform of a bouncing button http://www.ganssle.com/debouncing.htm then imagine that several of the edges occur in a rapid succession in between consecutive steps taken within the ISR, or in between invocations of the ISR.
JW
2021-01-08 08:54 AM
Really nice explanation!
Thank you so much...
Why cant you be my Prof. at University LOL.
He just says: find out yourself hihihi
what a *******...
Works now thanks...
2021-01-09 07:49 AM
Good information on basics:
https://www.embeddedrelated.com/showarticle/453.php
Parts 5 and 6 are about interrupts.
2021-01-09 12:22 PM
Oh thanks. This might be helpful in the future 😉