Skip to main content
stenasc
Associate III
March 10, 2013
Question

Debouncing interrupts

  • March 10, 2013
  • 14 replies
  • 3629 views
Posted on March 10, 2013 at 23:38

Hi,

In our system, we are trying to debounce switches on GPIO lines. Every msec the switch is sampled using TIM3. After 16 ticks, if the input has settled, the idea is to set the interrupt pending register and trigger the interrupt.

E.g.simple code to illustrate

if (db_count = 16)

   EXTI->PR = 0x00000200;

else

  EXTI_ClearITPendingBit(EXTI_Line9);

Is this code valid. ie Can I manually set the interrupt pending register like this. When I use this method, I never see the pending reg being set at all. Is there anything else I need to do in order to set this reg?

Many Thanks

Bob
    This topic has been closed for replies.

    14 replies

    mrupprath
    Associate II
    March 13, 2013
    Posted on March 13, 2013 at 12:51

    Hello;

    another approch for key debouncing

    1. You can buy special ''factory'' debnounced switches

    2. use an RC circuit to provide the input signal to the µC Port

    3. Use the ''one shot'' function of the build in µC Timers

     

      

    emalund
    Associate III
    March 13, 2013
    Posted on March 13, 2013 at 15:57

    if switch state == new switches return

    My take on this is,,,

    So if current switch state is the same as new switches...do nothing as the new switches hasn't changed...is this correct?

    YES

    if old switches == new switches set switch state and set action flag

    This to me means if the last switch value is the sames as the new switch values, which implies that no switch change has been made.

    NO, ''same as the new switch values'' is taken care of in the previous statement, THIS means that the switches read the same twice i.e. are debounced

    Erik
    Andrew Neil
    Super User
    March 14, 2013
    Posted on March 14, 2013 at 07:37

    another approch for key debouncing

     

     

    1. You can buy special ''factory'' debnounced switches

     

    2. use an RC circuit to provide the input signal to the µC Port

     

    3. Use the ''one shot'' function of the build in µC Timers

     

    4. You can buy ''switch debounce'' chips; eg,

    http://www.maximintegrated.com/datasheet/index.mvp/id/1896

    See also:

    http://www.maximintegrated.com/app-notes/index.mvp/id/1858

    A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
    stenasc
    stenascAuthor
    Associate III
    March 14, 2013
    Posted on March 14, 2013 at 09:27

    Hi Erik,

    Thanks for that...got you now.