About the difference between level triggering and edge triggering

Source: Internet
Author: User

Remember when you were in college, when the teacher talked about the falling edge trigger, how can we tell the difference between the drop-along trigger and the low-level trigger, at first glance, they appear to be the same, such as the keyboard scanner scanning keyboard is pressed:

An event is set to a low-level trigger "using the cycle time Scan query trigger condition is set up", when the initialization is high level that the event does not trigger, when the level suddenly changed to low level, after the scanning program performed here scanning, then found to be low so that the trigger execution;

An event is set to a falling edge trigger "adopt cycle time Scanning mode query trigger condition is established", when the initialization is high level that the event does not trigger, when the level suddenly changed to low level, after the scanning program to perform here scan, then found to be low so that the execution trigger;

Look at the results above are not the same!

However, we must not forget an important thing, that is, time is always walking, not forever fixed in a moment, especially single-chip microcomputer, computer, they just do not give them instructions to stop them, then they have been running, the same keyboard scanning program has been periodically scanning the keyboard! When the next scan cycle is over, you will find that the results of the two triggering methods are completely different.

Also take the keyboard scan to do examples, such as a simple keyboard scanning program design, it implements a keyboard corresponding to a light, when the keyboard press the next time (assuming that the key press on the low level, the release when the high level) corresponding LED status change once, that is, if the original is extinguished, when the keyboard is pressed for the first time will be lit , when the keyboard is pressed again, it will go off, then press the light point, then turn off the loop when it is pressed. Here we use the keyboard periodic scanning method to query whether the button is pressed:

1, in the 1th scan to the keyboard press, the result as we said earlier, whether it is a low-level trigger or a falling edge trigger results will trigger the event, where triggered when the indicator light is lit. Then the program continues to run ...

2, when the program continues to run to the 2nd Scan Keyboard button has not been released, the result is not the same.

low-level trigger : The trigger condition is still low, that is, the trigger condition is set up, then the execution of the event, that is, the LED status changes, when the indicator light from light to off;

Falling Edge Trigger : The trigger condition is still low, and the falling edge trigger condition is not true, then the event is not executed, that is, the indicator light remains in its original state.

3, when the program continues to run to the 3rd scan Keyboard When the key has not been released , the result:

Low Level trigger : The trigger condition is still low, that is, the trigger condition is set up, then the execution event, that is, the LED status change, when the indicator light is off and on;

Falling Edge Trigger : The trigger condition is still low, and the falling edge trigger condition is not true, then the event is not executed, that is, the indicator light remains in its original state.

The above is the most typical low-level trigger and falling edge of the difference between the trigger, I hope you can understand from the above example, grasp the low-level trigger and falling edge trigger, and in the actual learning and work can be flexibly applied to the appropriate trigger mode.

About the difference between level triggering and edge triggering

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.