1 2 Previous Next 15 Replies Latest reply on May 15, 2019 3:09 AM by YiZ_31

    fx3 interrupt

    gean_3054931

      Hi,

      I follow this thread in order to generate interrupt from fx3 gpio 25.

      the external switch is connected at gpio 25.if i press this switch,external pulse is going at gpo 25,but CyFxGpioIntrCb() call back function is not geeting called.

      I am blinking led that is connected at gpio 26 inside this call back(CyFxGpioIntrCb).led is not blinking inside this call back.

      please let me know the reason for this.I have attached the source code.

      thank you.

        • 1. Re: fx3 interrupt
          YiZ_31

          Hi,

           

          You should use CyU3PDeviceGpioOverride similar with you did to GPIO26 because GPIO 25 is GPIF IO as well.

           

          Regards,

          Eddie

          • 2. Re: fx3 interrupt
            gean_3054931

            Helllo,

            after calling CyU3PDeviceGpioOverride(25,cyTrue),problem is same.

            source code is attached.

            thank you.

            • 3. Re: fx3 interrupt
              YiZ_31

              Hi,

               

              I was able to trigger interrupt by your code. Maybe you should check your hardware.

              In the meantime, you should set gpioSimpleEn[] to 0, because you didn't use GPIO that can be selected here.

               

              Regards,

              Eddie

              • 4. Re: fx3 interrupt
                gean_3054931

                Hello eddie,

                I have cross checked my hardware.hardware is porper.

                how you are checking that interrupt in your code.are you using leds?

                please share your code also.

                void CyFxGpioIntrCb (

                        uint8_t gpioId /* Indicates the pin that triggered the interrupt  at GPIO 25*/

                        )

                {

                    CyBool_t gpioValue = CyFalse;

                    CyU3PReturnStatus_t apiRetStatus = CY_U3P_SUCCESS;

                   apiRetStatus = CyU3PGpioSetValue (26, CyTrue);

                 

                 

                 

                 

                           // Wait for two seconds

                    CyU3PThreadSleep(100);

                 

                 

                           // Set the GPIO 21 to low

                           apiRetStatus = CyU3PGpioSetValue (26, CyFalse);

                }

                LED at gpio 26 is not blinking when interupt is generated by gpio at 25.

                help me

                • 5. Re: fx3 interrupt
                  YiZ_31

                  Hi,

                   

                  I check the uart message you put in your code:

                  void

                  GpioInputThread_Entry (

                          uint32_t input)

                  {

                      uint32_t eventFlag;

                      CyU3PReturnStatus_t txApiRetStatus = CY_U3P_SUCCESS;

                   

                   

                      for (;;)

                      {

                          /* Wait for a GPIO event */

                          txApiRetStatus = CyU3PEventGet (&glFxGpioAppEvent,

                                  (CY_FX_GPIOAPP_GPIO_HIGH_EVENT | CY_FX_GPIOAPP_GPIO_LOW_EVENT),

                                  CYU3P_EVENT_OR_CLEAR, &eventFlag, CYU3P_WAIT_FOREVER);

                          if (txApiRetStatus == CY_U3P_SUCCESS)

                          {

                              if (eventFlag & CY_FX_GPIOAPP_GPIO_HIGH_EVENT)

                              {

                                  /* Print the status of the pin */

                                  CyU3PDebugPrint (4, "GPIO 25 is set to high\n");

                              }

                              else

                              {

                                  /* Print the status of the pin */

                                  CyU3PDebugPrint (4, "GPIO 25 is set to low\n");

                              }

                          }

                      }

                  }

                  I can get the uart message each time I trigger a interrupt.

                   

                  Regards,

                  Eddie

                  • 6. Re: fx3 interrupt
                    gean_3054931

                    Hello,

                    GpioInputThread_Entry is gpio threadentry function.

                    void CyFxGpioIntrCb (

                            uint8_t gpioId /* Indicates the pin that triggered the interrupt */

                            )

                    {

                        CyBool_t gpioValue = CyFalse;

                        CyU3PReturnStatus_t apiRetStatus = CY_U3P_SUCCESS;

                       apiRetStatus = CyU3PGpioSetValue (26, CyTrue);

                     

                     

                     

                     

                               // Wait for two seconds

                        CyU3PThreadSleep(100);

                     

                     

                               // Set the GPIO 21 to low

                               apiRetStatus = CyU3PGpioSetValue (26, CyFalse);

                     

                     

                        /* Get the status of the pin */

                        apiRetStatus = CyU3PGpioGetValue (gpioId, &gpioValue);

                        if (apiRetStatus == CY_U3P_SUCCESS)

                        {

                            /* Check status of the pin */

                            if (gpioValue == CyTrue)

                            {

                                /* Set GPIO high event */

                                CyU3PEventSet(&glFxGpioAppEvent, CY_FX_GPIOAPP_GPIO_HIGH_EVENT,

                                        CYU3P_EVENT_OR);

                            }

                            else

                            {

                                /* Set GPIO low Event */

                                CyU3PEventSet(&glFxGpioAppEvent, CY_FX_GPIOAPP_GPIO_LOW_EVENT,

                                        CYU3P_EVENT_OR);

                            }

                        }

                    }

                    are you able to print uart prints inside this CyFxGpioIntrCb  call back function?

                    please let me know.

                    thank you.

                    • 7. Re: fx3 interrupt
                      YiZ_31

                      Hi,

                       

                      In function GpioInputThread_Entry, CyU3PEventGet  is used to wait until one or more flags of interest have been signaled. It's used to wait for interrupt event here.

                       

                      Any blocking API calls including DebugPrint  cannot be made from GPIO interrupt callback handler.

                       

                      Regards,

                      eddie

                      • 8. Re: fx3 interrupt
                        gean_3054931

                        Hello,

                        what are the blocking API calls you are telling?

                        I am trying to blink led at gpio 26 inside GPIO interrupt callback handler.can i call CyU3PGpioSetValue () api inside c

                        gpio callback?

                        please verify above code attached to this thread.

                        thank you.

                        • 9. Re: fx3 interrupt
                          gean_3054931

                          Hello eddie,

                          I dont need any gpoievents(creat,set,get),my requirement is that i wanted to blink led inside gpio interrupt handler.

                          but not able to blink led inside interrpt handler,i can blink same led outside the handler.

                          thank you.

                          • 10. Re: fx3 interrupt
                            YiZ_31

                            Hi,

                             

                            I had done some tests to verify this. CyU3PThreadSleep is invalid in gpio interrupt handler. But the interrupt is still triggered. You will have to put the code of blinking LED outside the interrupt handler.

                             

                            Regards,

                            Eddie

                            • 11. Re: fx3 interrupt
                              gean_3054931

                              Hello eddie,

                              any other time delay inbuilt functions in fx3 other than CyU3PThreadSleep.

                              I modified the code as

                              void CyFxGpioIntrCb (

                                      uint8_t gpioId /* Indicates the pin that triggered the interrupt */

                                      )

                              {

                                  CyBool_t gpioValue = CyFalse;

                                  CyU3PReturnStatus_t apiRetStatus = CY_U3P_SUCCESS;

                                apiRetStatus = CyU3PGpioSetValue (26, CyTrue);

                              }

                              can i make led high inside handler which is intially low.(its not going to high when i tested with my board)

                              please check below code attached.

                              • 12. Re: fx3 interrupt
                                gean_3054931

                                Hello,

                                Is  apiRetStatus = CyU3PGpioSetValue (26, CyTrue); is also invalid inside handler??lt me know

                                 

                                thank you.

                                • 13. Re: fx3 interrupt
                                  gean_3054931

                                  Hello,

                                  do you suggest any other application example if its not suits for my requirements.

                                  thank you.

                                  • 14. Re: fx3 interrupt
                                    YiZ_31

                                    Hi,

                                     

                                    Yes, it's valid.

                                     

                                    I think the best way to achieve your goal is to put the code outside the handler just like our example code did. I have tested there and it works.

                                     

                                    Regards,

                                    Eddie

                                    1 2 Previous Next