1 2 Previous Next 22 Replies Latest reply on Aug 18, 2016 8:19 AM by dv89_9_1490111

    Debouncing multiple inputs

    dv89_9_1490111

      Hello,

         

      I have multiple inputs I need to debounce. All inputs are measured by GPIO Interrupt rising edge. I'm essentially counting  the positive edges (or pulses) to determine the frequency. I have implemented a debouncer that takes in data for 10 states and outputs a debounced value. My problem is that it does not debounce accurately. Any help? 

         

      Here is my ISR subroutine:

         

      CY_ISR(PortZeroISR){
          uint8 i,j;
          State[Index] = PortZero_INTSTAT & (0x07u << PortZero_SHIFT);
          
          ++Index;
          j=0xFF;
          for(i=0; i<10 ;i++)
              j = j & State[i];
          Debounced_state = j;
              
          if(Debounced_state == 0x01)
              FrequencyCounter++;
          
          if(Index >= 10)
              Index = 0;

          // Clear Pending Interrupt
          isr_PortZero_ClearPending();
          
          // Clear Pin I nterrupt
          PortZero_ClearInterrupt();

         

      }

         

      Thank you,

         

       

         

      Rick

        1 2 Previous Next