A method of key detection that breaks the textbook

Publisher:雅致人生Latest update time:2014-01-16 Source: 电源网 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Traditional textbooks, without exception, all use the delay method to detect key presses , but this method has many flaws. I’m posting this today to talk about it. I hope you guys will forgive me, but beginners can use it as a reference.

Traditional processing method: When a key is pressed for the first time, a subroutine with a delay of 10ms is executed to confirm whether the key level can maintain the closed state level. If the closed state level is maintained, it is confirmed that a key is really pressed, thereby eliminating the influence of jitter.

shortcoming:

1. The traditional processing method executes a 10ms delay subroutine, which will reduce the real-time performance of the program.

2. The traditional processing method confirms a key action by only checking twice, which may cause false key actions in a high anti-interference environment.

suggestion:

1. The recommended bounce time is 100ms to effectively pass the EFT noise certification.

2. It is recommended that the main program continuously check for a stable low level of 100ms before determining that the key has been pressed.

3. Similarly, the key can be determined to be popped up only if the high level is continuously checked for 100ms.

4. In order to ensure the execution efficiency of MCU, try not to use the Delay method for key detection . You can consider using the combination of polling detection and timer.

Here’s how:

After finding the low level, we read the level once in each cycle (time base) and compare it with the last time. If they are the same, the counter is incremented by 1 until a sufficient number of times are reached for processing. Otherwise, the counter is cleared and starts again.

Reference address:A method of key detection that breaks the textbook

Previous article:Some suggestions for newcomers who switch from 51 to ARM
Next article:Basic knowledge summary for novices: MCU literacy post, a must-read for beginners

Latest Power Management Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号