- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello!
I'm fairly new to this but have been poking away at the CY8CKIT-050 and it's a pretty cool kit!
I'm currently trying to get both a hardware and software interrupt setup. I will eventually be varying the PWM time so I have a slow timer setup (so I can adjust my PWM period for anywhere between 1 and 60s, with varying duty cycles). I am currently having it set to toggle on and off every 1 second. I have an LED setup to be triggered via the PWM output (LED3) and an LED setup to be triggered by the interrupt (LED4).
Below is my current setup:
My code looks like this:
CY_ISR(PWM_Interrupt_Handler)
{
Pin_LED4_Write(~Pin_LED4_Read());
}
int main()
{
CyGlobalIntEnable;
PWM_Start();
PWM_Interrupt_StartEx(PWM_Interrupt_Handler);
for(;;)
{
// I have other code running in here
}
}
I've been trying to do as much reading as I can (in the forums, watching videos on youtube, etc) but I can't seem to find the issue with either my understanding (maybe it's doing exactly what I have it programmed to do but my expectations are wrong) or I'm missing something basic that needs to be enabled for this to be up and working.
Any help someone could give me would be greatly appreciated. If you need any additional information, please let me know. Thanks a lot!
Solved! Go to Solution.
- Labels:
-
PSoC 5 Device Programming
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi jeremy,
Just enable "interrupt on terminal count event" too under PWM advanced configuration tab along with interrupt on compare event. Then it works. I don't know why without that option being enabled, interrupt do not triggered.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Need to clear interrupt inside isr routine, e.g. PWM_Interrupt_ReadStatusRegister();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the reply!
You are correct that I need to clear the interrupt flag but, unfortunately, that doesn't appear to be the problem. It actually never enters that interrupt routine in the first place, which I thought was odd. I thought I had initialized it correctly but maybe I'm still missing something. Here's my current code:
CY_ISR(PWM_Interrupt_Handler)
{
uint8 tempdata;
Pin_LED4_Write(~Pin_LED4_Read());
tempdata = PWM_ReadStatusRegister(); // Clear the interrupt
}
int main()
{
CyGlobalIntEnable;
PWM_Start();
PWM_Interrupt_StartEx(PWM_Interrupt_Handler);
for(;;)
{
// I have other code running in here
}
}
I forgot to post this in my last set of pictures but, if the issue is that the interrupt is not being triggered, this page will likely be important as well:
I'm hoping I'm just missing something really silly! Thanks for your help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please upload the project to review:
Select project name in explorer tree view, File->Create Archive
Bundle->Minimal
On Mar 30, 2018 1:58 PM, "jeremy_3270776" <community-manager@cypress.com>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi jeremy,
Just enable "interrupt on terminal count event" too under PWM advanced configuration tab along with interrupt on compare event. Then it works. I don't know why without that option being enabled, interrupt do not triggered.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, Amar!
Heh, I can't believe that's all it took . . . the funny thing is I cleared that because I didn't think I needed it . . .
I would've expected LED3 to toggle on and off as well on the PWM signal. Do you know why LED3 isn't turning on and off with the same frequency? I assumed they would both be acting the same. Maybe my understanding is wrong though.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
That is because of kill signal. Since PWM deadband is disabled and Kill signal is tied to high, the output of PWM remains at LOW.
Why did you connect kill input to HIGH? Here is a piece of datasheet explaining kill input.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Heh, I have no idea . . . I must've read it wrong (or I had it setup differently when I first implemented it). Regardless, I should've gone back to read about this.
Thanks for all your help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Welcome:)