PWM Interrupt Issue

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

cross mob
Anonymous
Not applicable

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:

pastedImage_0.png

pastedImage_2.png

pastedImage_6.png

pastedImage_7.png

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!

1 Solution
Anonymous
Not applicable

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.

View solution in original post

9 Replies
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

Need to clear interrupt inside isr routine, e.g. PWM_Interrupt_ReadStatusRegister();

Clearing Counter/Timer/PWM Interrupt in PSoC 3/5

0 Likes
Anonymous
Not applicable

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:

pastedImage_4.png

I'm hoping I'm just missing something really silly!  Thanks for your help!

0 Likes

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>

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

Sure, here's the file.  Thanks!

0 Likes
Anonymous
Not applicable

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.

Anonymous
Not applicable

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.

Anonymous
Not applicable

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.Kill_Signa;.PNG

0 Likes
Anonymous
Not applicable

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!

0 Likes
Anonymous
Not applicable

Welcome:)