Reading Interrupt Status Register (To clear active interrupt)

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

cross mob
Anonymous
Not applicable

Hi All,

   

im really struggeling clearing interrupt which is driven by PWM output (pwm).

   

once the interrupt is driven, i cant clear it and it stays on (Clear Pending isnt working).

   

 

   

Please help me..

   

Thank you 🙂

0 Likes
8 Replies
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Several questions -

   

 

   

1) What is the period of the PWM ?

   

2) What does the code look like in ISR ? Normally you want to set a simple flag

   

and exit, servicing ISR in main(). You especially do not want to call f()'s, that

   

creates a lot of stack push and latency.

   

3) What is the function of the ISR ? To do what ?

   

 

   

Regards, Dana.

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

Is your ISR level- or edge-triggered? If its level-triggered, it will re-trigger as long as the PWM output is high.

0 Likes
Anonymous
Not applicable

Upload your project would help.

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

First of all i would like to thank you all for the replies.

   

 

   

Dana:

   

1. PWM Freq. is 2KHz

   

2+3. The code inside the ISR is only changing the value in some flag (uint8)

   

no function() calling inside or doing something complicated.

   

 

   

Hli:

   

My ISR is RISING-EDGE triggred.

   

 

   

Atached is the component connection and the code sinpest.

   

 

   

Code:

   

CY_ISR_PROTO(CC_Battery_Tester_SM_1_1MSEC_IRQ)
{
    CC_Battery_Tester_SM_1_Pin_1_Write (onOFFFlag);
    if (onOFFFlag == 1)
    {
        onOFFFlag = 0;
    }else
    {
        onOFFFlag = 1;
    }
    CC_Battery_Tester_SM_1_ISR_1MSEC_ClearPending ();
}

   

 

   

Thank you all.

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

The interrupts are cleared by calling the PWM_ReadStatusRegister() function (or PWM_1msec_ReadStatusRegister() in your case). _ClearPending only clear interrupts which have happened already but where the ISR has not been called yet (e.g. when interrupts are globally disabled). See also page 34 in the PWM datasheet.

   

Also, I think your function names are not right: the ISR component is called ISR_1MSEC, but you call e.g. CC_Battery_Tester_SM_1_ISR_1MSEC_ClearPending. I think this should be just ISR_1MSEC_ClearPending .

0 Likes
Anonymous
Not applicable

Its working now!! 🙂

   

Reason for why it didnt work for me:

   

<HeaderFile.h>

   

CY_ISR_PROTO(`$INSTANCE_NAME`_1MSEC_ISR);

   

 

   

<CodeFile.c>
CY_ISR_PROTO(`$INSTANCE_NAME`_1MSEC_ISR) //Wrong Function name is Written: Should be only CY_ISR(`$INSTANCE_NAME`_1MSEC_ISR)
{
    `$INSTANCE_NAME`_Pin_1_Write (onOFFFlag);
    if (onOFFFlag == 1)
    {
        onOFFFlag = 0;
    }else
    {
        onOFFFlag = 1;
    }
    `$INSTANCE_NAME`_ISR_1MSEC_ClearPending ();
   
    /* PSoC3 ES1, ES2 RTC ISR PATCH  */
    #if(CYDEV_CHIP_DIE_EXPECT == CYDEV_CHIP_DIE_LEOPARD)
        #if((CYDEV_CHIP_REV_EXPECT <= CYDEV_CHIP_REV_LEOPARD_ES2) && (`$INSTANCE_NAME`_ISR_1MSEC__ES2_PATCH ))     
            `$INSTANCE_NAME`_1MSEC_ISR_ISR_PATCH();
        #endif
    #endif   
}

   

 

   

Solution:

   

<HeaderFile.h>

   

CY_ISR_PROTO(`$INSTANCE_NAME`_1MSEC_ISR);

   

 

   

<CodeFile.c>
CY_ISR(`$INSTANCE_NAME`_1MSEC_ISR)
{
    `$INSTANCE_NAME`_Pin_1_Write (onOFFFlag);
    if (onOFFFlag == 1)
    {
        onOFFFlag = 0;
    }else
    {
        onOFFFlag = 1;
    }
    `$INSTANCE_NAME`_ISR_1MSEC_ClearPending ();
   
    /* PSoC3 ES1, ES2 RTC ISR PATCH  */
    #if(CYDEV_CHIP_DIE_EXPECT == CYDEV_CHIP_DIE_LEOPARD)
        #if((CYDEV_CHIP_REV_EXPECT <= CYDEV_CHIP_REV_LEOPARD_ES2) && (`$INSTANCE_NAME`_ISR_1MSEC__ES2_PATCH ))     
            `$INSTANCE_NAME`_1MSEC_ISR_ISR_PATCH();
        #endif
    #endif   
}

   

 

   

Again, Thank you all for your help 🙂

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

It looks as if you created your own component or did you make changes to the api-files from where the code is generated?

   

 

   

Bob

0 Likes
Anonymous
Not applicable

I've made my own component and created my own interrupt.

0 Likes