fx3 interrupt

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
gean_3054931
Level 5
Level 5
10 likes given 5 likes given First like received

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.

0 Likes
15 Replies
YiZ_31
Moderator
Moderator
Moderator
1000 replies posted 750 replies posted 500 replies posted

Hi,

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

Regards,

Eddie

0 Likes
lock attach
Attachments are accessible only for community members.

Helllo,

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

source code is attached.

thank you.

0 Likes
YiZ_31
Moderator
Moderator
Moderator
1000 replies posted 750 replies posted 500 replies posted

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

0 Likes

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

0 Likes
YiZ_31
Moderator
Moderator
Moderator
1000 replies posted 750 replies posted 500 replies posted

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

0 Likes

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.

0 Likes
YiZ_31
Moderator
Moderator
Moderator
1000 replies posted 750 replies posted 500 replies posted

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

0 Likes

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.

0 Likes

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.

0 Likes
YiZ_31
Moderator
Moderator
Moderator
1000 replies posted 750 replies posted 500 replies posted

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

0 Likes
lock attach
Attachments are accessible only for community members.

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.

0 Likes

Hello,

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

thank you.

0 Likes

Hello,

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

thank you.

0 Likes
YiZ_31
Moderator
Moderator
Moderator
1000 replies posted 750 replies posted 500 replies posted

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

0 Likes
YiZ_31
Moderator
Moderator
Moderator
1000 replies posted 750 replies posted 500 replies posted

Hi ,

Or you could try use CyU3PBusyWait(1000) contained in cyu3utils.h. If you replace it with CyU3PThreadSleep, the LED will blink more clearer.

Regards,
Eddie

0 Likes