Principle of MCU key debounce

Publisher:数字冒险Latest update time:2018-11-26 Source: eefocusKeywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere


From the above figure, we can see that there is a difference between the ideal waveform and the actual waveform. The actual waveform has jitter at the moment of pressing and releasing. The length of the jitter time is related to the mechanical characteristics of the key, generally 5~10ms. Usually we press the key manually and then release it. The stable closure time in this action exceeds 20ms. Therefore, the microcontroller must add a de-jitter operation when detecting whether the keyboard is pressed. There are dedicated de-jitter circuits and dedicated de-jitter chips, but usually we can solve the jitter problem by using software delay method.


\/* Software debounce*/




if (0 == K1 ) //If a key is pressed




{


delay_ms(8); //delay for a while to debounce


if (0 == K1) //If a key is really pressed, it is detected to be in a stable closed state


{


... //What to do after pressing the button


}


while(!K1); // Release detection, if you hold down the button, it will continue in the loop



}


Keywords:MCU Reference address:Principle of MCU key debounce

Previous article:VGA Timing and Its Principle
Next article:The role of interrupts

Recommended ReadingLatest update time:2024-11-16 14:33

Research on Fast Algorithm for Audio Frequency Spectrum Display Using Single Chip Microcomputer
1 Introduction In home theater, karaoke and other audio systems, real-time display of the spectrum of music signals will add a lot of color to the audio system. At present, most of the actual audio system products use the following two methods to realize audio spectrum display: one is to use hardware fi
[Microcontroller]
Design of LED dot matrix handwriting screen using PIC microcontroller
This paper uses PIC 16F877A microcontroller as the main core control element to design a 32×32 LED dot matrix module writing display screen. It is mainly composed of a light pen module and a dot matrix display module. The light pen module uses the photoelectric characteristics of the photoresistor to realize the mic
[Microcontroller]
Design of LED dot matrix handwriting screen using PIC microcontroller
MCU prices cut in half, has the automotive chip panic reached a turning point?
Semiconductor chips, which once had high prices, have recently reached a turning point. According to media reports, the storm of semiconductor chip order cuts and price cuts has intensified, and even the quotations of MCUs, which were previously in short supply, have begun to drop sharply. There are also reports that
[Automotive Electronics]
MCU prices cut in half, has the automotive chip panic reached a turning point?
Design idea of ​​using 51 single chip microcomputer and CPLD to construct complex circuit system
  I. Introduction   The single-chip microcomputer market can be described as a giant, and the 51 single-chip microcomputer has more users. There is no need to introduce the 51 single-chip microcomputer in detail. One point must be emphasized here. As long as you are proficient in the 51 single-chip microcomputer, it w
[Microcontroller]
Design idea of ​​using 51 single chip microcomputer and CPLD to construct complex circuit system
Function parameter transfer in arm microcontroller
1. When the function has less than 4 parameters, they are passed directly through registers R0-R3. If the number of parameters exceeds 4, they are passed through the stack. 2. When passing a structure, if the number of elements in the structure is less than 4, they are also passed through R0, R1, R2, and R3. If ther
[Microcontroller]
Low-power MCU system hardware and software design considerations
  The low power consumption of electronic products often gives product designers a headache but they have to face it. The power consumption of a system with a single-chip microcomputer (MCU) as the core is mainly composed of the power consumption of the single-chip microcomputer and the power consumption of the single-
[Microcontroller]
The microcontroller modifies the underlying function putchar() to implement printf() output on the LCD
The microcontroller source program is as follows: #include reg51.h #include intrins.h #include stdio.h #include LCD.h /************************** Main function ******************************/ void main(void){         LcdInitiate();         WriteAddress(0x00);         printf("Hello Everybodyn");         printf("P
[Microcontroller]
The microcontroller modifies the underlying function putchar() to implement printf() output on the LCD
51 MCU 8255 driver C program
/*--------------------------------------------------------------------------------------------------------------------------------  Library file name: driver8155.h  Function description: Driver 8155, no need to understand the working principle of 8255, transparently operate the three input and output ports PA, PB, PC
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号