- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 🙂
- Labels:
-
PSoC 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is your ISR level- or edge-triggered? If its level-triggered, it will re-trigger as long as the PWM output is high.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Upload your project would help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've made my own component and created my own interrupt.