void ISR_ClearPending(void) for GPIO with PSoC4000S

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

cross mob
YoIs_1298666
Level 5
Level 5
250 sign-ins 100 replies posted 100 sign-ins

Hello,

The following is written in void ISR_ClearPending (void) explanation.

pastedImage_0.png

What does the NOTE description say other than "void ISR_ClearPending(void)" to clear interrupt pending in GPIOs?

Best regards,

Yocchi

0 Likes
1 Solution

Hi YoIs_1298666​,

I agree. ClearPending() clears the pending  state of the interrupt in the NVIC controller to prevent them from being executed again by the CPU and Pin_ClearInterrupt() clears the interrupt at source. It is better to clear the interrupt at source using ClearInterrupt first and then clear the state (if pending) of the interrupt from the NVIC controller.

Regards,

Bragadeesh

Regards,
Bragadeesh

View solution in original post

0 Likes
3 Replies
VenkataD_41
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hi Yoshi-san,

The description says to clear the interrupt bit of the corresponding IP block. Generally the interrupt bits of the IP blocks like GPIO, Timer are sticky. So the user has to call Pin_ClearInterrupt() API to clear the pin interrupt,  Timer_ClearInterrupt() in case of timer.

If you refer the Interrupts code example in PSoC Creator the ISR definition will be as follows:

CY_ISR(GPIOIsrHandler)

{

    /* Clear pending Interrupt */

    isr_GPIO_ClearPending();

   

    /* Clear pin Interrupt */

    Pin_Sw_ClearInterrupt();

   

    /* Turn On the LED */

    LED_Isr_Write(LIGHT_ON);

    /* Cause nested software interrupt after 1000 ms */

    CyDelay(1000u);

    CyIntSetPending(NESTED_ISR);

    /* Turn Off the LED */

    LED_Isr_Write(LIGHT_OFF);

}

Here please note that both isr_GPIO_ClearPending(); and Pin_Sw_ClearInterrupt(); should be called.

Hope this answers your question.

Thanks

Ganesh

0 Likes

Hello Ganesh-san,

Thank you very much for your help.

In case of GPIO interrupt, unnecessary interrupts will occur unless the order is as follows.

  /* Clear pin Interrupt */ 

  Pin_Sw_ClearInterrupt();

  /* Clear pending Interrupt */ 

  isr_GPIO_ClearPending(); 

What do you think?

Best regards,

Yocchi

0 Likes

Hi YoIs_1298666​,

I agree. ClearPending() clears the pending  state of the interrupt in the NVIC controller to prevent them from being executed again by the CPU and Pin_ClearInterrupt() clears the interrupt at source. It is better to clear the interrupt at source using ClearInterrupt first and then clear the state (if pending) of the interrupt from the NVIC controller.

Regards,

Bragadeesh

Regards,
Bragadeesh
0 Likes