Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.
If you are using interrupts simply read your button(s) periodically (for example 50 times per second).
All you have to do is take the last button state, compare it to the current button state and if anything has changed report it to your main program and keep the current button state as last button state.
I agree with C-Man. In most applications, the simplest solution is to sample the button at a steady rate. Use a D-flop and clock, or a software timer interrupt. I usually set the sampling period to be at least twice the worst-case bounce duration. If the button bounces 10 ms, I'll set the clock to 50 Hz.
I'm using RTOS and never had such problems. The task that scans the keyboard, wakes up every 10-20ms and read the key status. If there is toggle 1-0 I report key pressed. Using RTOS is very easy to build "long press" buttons, where you can change the functionality of the same key - fast press - INC/DEC, long press - ENTER.
Trust me, for keys and buttons scan RTOS is one excellent solution.
While the task is waiting (10-20ms) other tasks continue working. The whole project becomes very reliable, with smooth operation.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.