debouncer circuit

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

I have a switch connected to PRoC.

   

How to implement debouncer circuit in PRoC as it does not has logic gates/FF?

0 Likes
4 Replies
Anonymous
Not applicable

How about software based debouncer? Something like following:

   

#define Button_PUSHED_MASK               0x01
#define Button_DETECTED_MASK            0x02

   

#define SWITCH_DEBOUNCE_DELAY                  400   /* Counter value equivalent to debounce time */

   

​uint8 buttonStatus =0;

   

void CheckButtonPress(void)
{   
    if(Button_Pin_Read() == FALSE)
    {
        /* Register the button press for the first time and check if button debouncing is completed */
        if(!(buttonStatus & (Button_PUSHED_MASK | Button_DETECTED_MASK)))
        {
            /* If button press not registered, register the button press event*/
            buttonStatus = buttonStatus | Button_PUSHED_MASK;
            
            /* Initiate a debounce counter */
            switchDebounceTimer = SWITCH_DEBOUNCE_DELAY;
        }
        else if( (buttonStatus & Button_PUSHED_MASK) && (switchDebounceTimer == 0) )
        {
            /* If debounce counter has elapsed, then register a button press detect event */
            buttonStatus = buttonStatus & (~Button_PUSHED_MASK);
            buttonStatus = buttonStatus | Button_DETECTED_MASK;
        }
    }
    else
    {
        if((buttonStatus & Button_DETECTED_MASK))
        {
            /******USER_CODE: Add your custom code for push button based events or debugging code*********/
            
            /*********************************************************************************************/
            
            /* Reset button status flag */
            buttonStatus = buttonStatus & ( ~(Button_DETECTED_MASK) );
        }
        /* If button press is not detected and the switch debounce timer has expired, clear the button press status
         * in the ButtonStatus register */
        else if((buttonStatus & Button_PUSHED_MASK) && switchDebounceTimer == 0)
        {
             buttonStatus = buttonStatus & (~Button_PUSHED_MASK);
        }
    }
 }

   

 

   

The above is assuming that the input pin ''Button_Pin'' is configured as resistive pull-up. Make sure that you have a timer based system that decrements 'switchDebounceTimer ' whenever it is non-zero. 

0 Likes
lock attach
Attachments are accessible only for community members.
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Some ref material -

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

thanks roit and Dana.

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Glad I could be of assistance.

   

 

   

Regards, Dana.

0 Likes