1. Compare the method of detecting keystrokes by delay and debouncing with the method of detecting keystrokes by interruption: For the method of detecting keystrokes by interruption, if you do not do some processing in the program to detect whether the keystrokes are pressed again, its accuracy is not as reliable as the method of detecting keystrokes by delay and debouncing.
2. The reason is: when we use interrupts to detect buttons, there is no delay in the interrupt program, then there will be a problem. When the button is pressed, there may be multiple jitters. Although we set the falling edge to trigger the interrupt, there may also be multiple falling edges in these multiple jitters, so the interrupt may be triggered multiple times.
3. The only solution is to use delay. The corrected code is shown in Figure 3 below. However, the code in P90 of the "STM32 Library Development Practical Guide" will cause false triggering.
Figure 1: Traditional delay debounce detection key program
Figure 2: Rough delay function
Figure 3: Corrected code for detecting keystrokes using interrupts
4. So the question is, if delay is also used in the interrupt program, what is the difference between it and the traditional delay debouncing?
The difference is: the traditional delay debouncing program should be written in the while loop of the main function, constantly detecting whether the button is pressed, occupying CPU resources in vain; while the interrupt method will not affect the execution of other programs. Only when the button is pressed will the interrupt be triggered and the interrupt service program will be entered.
Previous article:STM32 software key debounce
Next article:STM32F1xx serial port control light switch experiment
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- ESP32 configures WIFI via Bluetooth
- LT5400AIMS8E-4#PBF If you need help with replacement, or provide this material directly, thank you!
- MBUS front-end protection
- KiCad Simplified Chinese Manual
- Automotive electronics technology - hardware, software, system integration and project management
- When the pull-up and pull-down resistors are not turned on, it is in floating mode. What is the principle that may cause high power consumption?
- Vicor Power Solutions to Maximize Performance for AI, HPC and Data Computing
- Battery Management Chip BQ28Z610 Problem Collection
- From simulation to realization
- 【DFRobot motor driver】+ unboxing and testing