4 Replies Latest reply on May 3, 2018 3:33 AM by GerrikoIoT

    How does one clear a Pin press"memory"

    GerrikoIoT

      I am probably making a rather silly mistake but this scenario has got me stumped.

       

      I have two input pins which each have an interrupt attached.

       

      I have created logic that has one pin interrupt enabled when the other is disabled and then it swaps upon button press. A green and a red LED to indicate the different button presses. Now this works fine if each button is pressed once. However, if I press one of the buttons twice and then when I press the second button it still shows the first button sequence after this second button, as in it has in memory the 2nd press of the 1st button. Why is this?

       

      Sequence is:

      Press Button_1 once. isr_ResetBtn_Enable(); and isr_StartBtn_Disable(); LEDgreen ON then OFF

      Now Press Button_2 once. Then isr_StartBtn_Enable(); and isr_ResetBtn_Disable(); LEDred ON then OFF.

       

      Press Button_1 TWICE. isr_ResetBtn_Enable(); and isr_StartBtn_Disable(); LEDgreen ON then OFF

      Now Press Button_2 once. isr_StartBtn_Enable(); and isr_ResetBtn_Disable(); LEDred ON then OFF.... then LEDgreen ON then OFF ????

       

      How do I ignore or "clear" that second button_1 press?

       

      Here is code snippet within main()

       

          /* Enable the start pin interrupt */
          CyGlobalIntEnable;
          isr_StartBtn_Disable();
          isr_ResetBtn_Disable();
          
          /* Start the TCPWM Component */
          //Timer_Start();
          
          
          for(;;)
          {
              if (Started) {
                  /* Handle the Period of Play Logic */
                  if (StartButtonIntEnabled) {
                      StartButtonIntEnabled = false;
                      /* Turn On the Red LED */
                      LED_TimeOutReq_Write(LIGHT_ON);
                      CyDelay(500u);
                      LED_TimeOutReq_Write(LIGHT_OFF);
                      
                      isr_StartBtn_Disable();
                      isr_ResetBtn_Enable();
                  }
              }
              else {
                  if (!StartButtonIntEnabled) {
                      StartButtonIntEnabled = true;
                      /* Turn On the Red LED */
                      LED_TimeOutON_Write(LIGHT_ON);
                      CyDelay(500u);
                      LED_TimeOutON_Write(LIGHT_OFF);
                      
                      isr_ResetBtn_Disable();
                      isr_StartBtn_Enable();
                  }
              }
          }
      

       

      CY_ISR(isr_StartBtnHandler)
      {
          /* Clear pending Interrupt */
          isr_StartBtn_ClearPending();
          
          /* Clear pin Interrupt */
          Pin_Start_ClearInterrupt();
          
          Pin_Reset_Read();
          
          /* Set the Start flag to true */
          Started = true;
      }
      CY_ISR(isr_ResetBtnHandler)
      {
          /* Clear pending Interrupt */
          isr_ResetBtn_ClearPending();
          
          /* Clear pin Interrupt */
          Pin_Reset_ClearInterrupt();
          
          Pin_Start_Read();
          
          /* Set the Start flag to false */
          Started = false;
      }