Pular para o conteúdo principal
Renesas Brasil - Knowledgebase

Does key interrupt cope with chattering in terms of hardware?

Latest Updated:01/01/2008


I am trying to perform switch input using the key interrupt function. Does key interrupt cope with chattering in terms of hardware?


No, no chattering prevention function is provided internally as hardware.
Noise elimination done internally in the microcontroller may be on the order of several tens of ns (using analog delay) to several µs (noise elimination by sampling) at most. Normally, mechanical vibrations such as chattering last several ms, which is an extremely long time as seen from the operation of the microcontroller. No filter capable of eliminating noise over such long durations is provided internally.
Therefore, if a chattering countermeasure is required, set up a waiting period outlasting the chattering through a software-implemented timer at the start of key interrupt processing, and then perform key verification.
For more information on key input and key interrupts, refer to "Key Switch Input into Microcontroller".

Since the CPU goes into an interrupt prohibit state when a key interrupt is acknowledged and the operation branches to an interrupt vector, multiple key interrupts cannot be acknowledged simultaneously. However, the interrupt request flag is set by chattering. Thus the interrupt request flag must be cleared prior to return from a key interrupt.
Moreover, caution is required about the fact that chattering also occurs when a key is released, as shown in the following figure. This can be handled through the elimination of chattering via a software-implemented timer.
Suitable Products