I am using CCG3PA with PSoC Creator. How do I setup interrupt for both a rising and falling edge of an input signal?

Announcements

Live Webinar: USB-C adoption. Simple & Cost-efficient solutions | April 18th @9am or 5pm CEST. Register now !

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

cross mob
AlMa_1521636
Level 1
Level 1
First like given Code Expert

I am using CCG3PA with PSoC Creator. I have a signal being input to pin 10 called Int_Rdy that I would like an interrupt that will trigger on both rising and falling edge of the signal. I would like to be able to read the Int_Rdy signal level from within the interrupt routine. How do I do this?

0 Likes
1 Solution
ShifangZ_26
Moderator
Moderator
Moderator
10 likes given 250 sign-ins 1000 replies posted

Hi Allen,

1. You could refer Cypress standard example project to implement Interrupt. This Application can help you understand Interrupt in M0+ core to help you out.

https://www.cypress.com/documentation/application-notes/an90799-psoc-4-interrupts

https://www.cypress.com/documentation/code-examples/ce210558-psoc-4-gpio-interrupt

2. If you just need a example code for both edge, I have a example for your referring.

a. Add a GPIO and ISR type in your project.

pastedImage_2.png

pastedImage_3.png

b. In your project, You shall add below code into your project.

(1) Interrupt handle function

//LISZ

/*

*   Function

*/   

void change_xxxx(void)

{

   

    if (GPIO_0_Read() == false)

    {

.... //<< Add failing edge function here

    }

    if (GPIO_0_Read() == true)

    {

....//<< Add rising edge function here

    }

}

/*

*   Interrupt Service Routine to handle the interrupts triggered

*   on the falling edge of the GPIO_0 input signal

*/

CY_ISR(GPIO_ISR_handler)

{  

    GPIO_0_ClearInterrupt();   // Clears any active interrupts attached with the GPIO_0 component   

   

    change_xxxx();

}

(2) Initial interrupt

    GPIO_0_ClearInterrupt();   // Clears any active interrupts attached with the USER_BUTTON component   

   

    /* Sets up the interrupt to function and sets address as the ISR vector for the interrupt */

    GPIO_ISR_StartEx(GPIO_ISR_handler);

Best Regards,

Lisa

View solution in original post

0 Likes
1 Reply
ShifangZ_26
Moderator
Moderator
Moderator
10 likes given 250 sign-ins 1000 replies posted

Hi Allen,

1. You could refer Cypress standard example project to implement Interrupt. This Application can help you understand Interrupt in M0+ core to help you out.

https://www.cypress.com/documentation/application-notes/an90799-psoc-4-interrupts

https://www.cypress.com/documentation/code-examples/ce210558-psoc-4-gpio-interrupt

2. If you just need a example code for both edge, I have a example for your referring.

a. Add a GPIO and ISR type in your project.

pastedImage_2.png

pastedImage_3.png

b. In your project, You shall add below code into your project.

(1) Interrupt handle function

//LISZ

/*

*   Function

*/   

void change_xxxx(void)

{

   

    if (GPIO_0_Read() == false)

    {

.... //<< Add failing edge function here

    }

    if (GPIO_0_Read() == true)

    {

....//<< Add rising edge function here

    }

}

/*

*   Interrupt Service Routine to handle the interrupts triggered

*   on the falling edge of the GPIO_0 input signal

*/

CY_ISR(GPIO_ISR_handler)

{  

    GPIO_0_ClearInterrupt();   // Clears any active interrupts attached with the GPIO_0 component   

   

    change_xxxx();

}

(2) Initial interrupt

    GPIO_0_ClearInterrupt();   // Clears any active interrupts attached with the USER_BUTTON component   

   

    /* Sets up the interrupt to function and sets address as the ISR vector for the interrupt */

    GPIO_ISR_StartEx(GPIO_ISR_handler);

Best Regards,

Lisa

0 Likes