- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a switch connected to PRoC.
How to implement debouncer circuit in PRoC as it does not has logic gates/FF?
- Labels:
-
BLE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thanks roit and Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Glad I could be of assistance.
Regards, Dana.