4 Replies Latest reply on Jul 6, 2015 5:58 AM by user_246598725

    push button with denouncing implemented

    akshay.bha

       Hi there,

         

      I have gott switch connected to Psoc5 and would like to turn on LED, whenever button is pressed, looking for project how to actually do it. I also would like to implement with debouncing circuit, so not sure how could I do that in cypress.

         

      I tried something like this but doesn't work

         

       

         

      #include <device.h>

         

      volatile uint8  switchFlag = 0u;

         

      CY_ISR_PROTO(SW_ISR_Handler);

         

       

         

      int main()

         

      {

         

          CyGlobalIntEnable;

         

          Isr_SW2_StartEx(SW_ISR_Handler);

         

          for(;;)

         

          {

         

              if(switchFlag)

         

              {

         

                  LED_Write(1);          

         

                  switchFlag = 0u;

         

                     CyDelay(5000);

         

              }

         

          }

         

      }

         

       

         

      CY_ISR(SW_ISR_Handler)

         

      {

         

          switchFlag = 1u;

         

      }

         

       

         

      Top Design is attached.. If any mistake then let me know.

         

      Any help woud be great .

         

       

         

      Thanaks 

         

      AK

        • 1. Re: push button with denouncing implemented
          user_14586677

          Use the debouncer component -

             

           

             

             

           

             

          There is an example project you can look at, start page, "Find Example project" link

             

           

             

           

             

           

             

          Regards, Dana.

          • 2. Re: push button with denouncing implemented
            akshay.bha

            Hi Dana,

               

            Thanks for your reply.

               

            I did use debouncer as you can see schematics in attachment, I used example code, but it doesn't work , you can see in above thread, my connections are on top design are right. Just would like to confirm that I have applied 3.3 V to switch and connected to one of pin and set as input, will that work as input interrupt ?

               

            So, I am not sure what is wrong , Is above code and schematics right ? 

            • 3. Re: push button with denouncing implemented
              user_14586677

              Post a project archive -

                 

               

                 

                  

                 

                        

                 

              “File”                                                             Creator

                 

              “Create Workspace Bundle”

                 

                

                 

              Regards, Dana.

              • 4. Re: push button with denouncing implemented
                user_246598725

                Hi AK,

                   

                 

                   

                it depends on how your input pin is configured. You wrote that the switch is connected to 3.3V. So your input pin must be configured for input with pull-down enabled, otherwise you wouldn't get the low voltage value when the button is not pressed.

                   

                To be compatible with other MCUs it's recommended to connect the switch to GND, because pins are configured for input with pull-up resistor on most MCUs.

                   

                 

                   

                Regards,

                   

                 

                   

                Ralf