ISR interrupt only firing once on PWM interrupt

Discussion of the PSoC Creator Integrated Development Environment for PSoC3 & PSoC5 devices.

Moderator: ericb

ISR interrupt only firing once on PWM interrupt

Postby dpfahler » Tue Mar 02, 2010 3:13 pm

Preface, I'm brand new to firmware design, and have been testing out the PSoC 3 for only a day.

My colleague and I are trying to set up a PWM that has an interrupt that fires on a compare1. I set my clock to 60Hz, PWM period of 60, and CMP value 1 of 30 with a less or equal comparison type.

I also created isr_1 in which I am only trying to do a trivial task on the interrupt.

my main.c contains the following lines.
CYGlobalIntDisable;
clock_1_Start();
Main_PWM_Start();
isr_1_Start();
CYGlobalIntEnable;
for(;;);

I would suspect that the code I have in the CY_ISR(isr_1_Interrupt) method would be triggered each second, but am quite new to this, and would understand if it fired every half second or every 2 seconds, however I can only get the interrupt to fire once period.

I have set a logic low reset, a logic high enable, a digital LED output to the PWM (which fires each second, So I know that the pwm is working), and the isr is hooked to the interrupt.

Please let me know if you see anything incorrect about my assumptions and/or setup. The main goal here is to attempt to make a configuration similar to what our old board use to do in order to control a motor. There may be a much better way, but the exercise of understanding interrupts seems like one I should master before passing my opinions of the IDE on to my supervisor.

Thanks for your time.
dpfahler
Newbie
Newbie
 
Posts: 4
Joined: Tue Mar 02, 2010 2:48 pm

Re: ISR interrupt only firing once on PWM interrupt

Postby slandrum » Tue Mar 02, 2010 5:38 pm

I suspect the problem is in your interrupt handler.
slandrum
The Big Cheese
The Big Cheese
 
Posts: 453
Joined: Fri Feb 29, 2008 11:38 am
Location: California

Re: ISR interrupt only firing once on PWM interrupt

Postby dpfahler » Wed Mar 03, 2010 7:41 am

Can you point me to an example of a correctly implemented interrupt handler. I was assuming that the only change necessary was in the CY_ISR(isr_1_Interrupt) method. Do I also need to include something in the main.c file.

Thanks for your response,
David
dpfahler
Newbie
Newbie
 
Posts: 4
Joined: Tue Mar 02, 2010 2:48 pm

Re: ISR interrupt only firing once on PWM interrupt

Postby dpfahler » Wed Mar 03, 2010 7:46 am

All I am doing is trying to hit a breakpoint over and over, so I put a breakpoint on i++ just to make sure I constantly break. Do I need to be resetting anything?

CY_ISR(isr_1_Interrupt)
{
/* Place your Interrupt code here. */
/* `#START isr_1_Interrupt` */
int i = 0;
i++;
/* `#END` */
}
dpfahler
Newbie
Newbie
 
Posts: 4
Joined: Tue Mar 02, 2010 2:48 pm

Re: ISR interrupt only firing once on PWM interrupt

Postby sandeepSutradhar » Thu Mar 04, 2010 1:11 am

you need to clear the isr bit by using the API PWM_readStatus Register() in the isr hadler.
sandeepSutradhar
Bite-Size Cheese
Bite-Size Cheese
 
Posts: 18
Joined: Mon Dec 14, 2009 8:41 am

Re: ISR interrupt only firing once on PWM interrupt

Postby dpfahler » Thu Mar 04, 2010 2:14 pm

Thanks. That allowed me to hit the interrupt twice. Now I will continue to figure out how to continue hitting it.
dpfahler
Newbie
Newbie
 
Posts: 4
Joined: Tue Mar 02, 2010 2:48 pm

Re: ISR interrupt only firing once on PWM interrupt

Postby abitkin » Thu Mar 04, 2010 2:36 pm

You have to clear the interrupt every time it is hit. The interrupt bit is effectively sticky and thus must be cleared manually.
abitkin
The Big Cheese
The Big Cheese
 
Posts: 208
Joined: Wed Sep 16, 2009 11:54 am

Re: ISR interrupt only firing once on PWM interrupt

Postby Fix » Sat Dec 14, 2013 7:30 am

for me the Interrupt is only executed once...
I included <Timer_PeriodCapture.h> and in isr I've only "interrupt_PeriodCapture = 1; Timer_PeriodCapture_ReadStatusRegister();".
interrupt_PeriodCapture is checked and cleared in main but the 2nd time while(!interrupt_PeriodCapture); locks up.

ideas?
Fix
Newbie
Newbie
 
Posts: 4
Joined: Sat Dec 14, 2013 7:20 am

Re: ISR interrupt only firing once on PWM interrupt

Postby bobmarlowe » Sat Dec 14, 2013 9:46 am

Best is always to upload your complete project here, so that we all can have a look at. Use Creator -> File-> Create Workspace Bundle (minimal) and upload the resulting archive here.
Do you use a development kit? Which one??


Bob
User avatar
bobmarlowe
The Big Cheese
The Big Cheese
 
Posts: 1490
Joined: Thu Oct 06, 2011 2:03 am
Location: Germany

Re: ISR interrupt only firing once on PWM interrupt

Postby Fix » Sun Dec 15, 2013 3:40 am

Hello

I use CY8CKIT-001 with PSoC 5 (not LP).

I hope the Project works. I have deleted some Folders which I think are unnecessary Project copies.

thx

p.s. it's not that important anymore since it's a School Project and I think I won't be able to implement this anymore.
it was just a test and I asked for interest...
Attachments
Waage.cywrk.Archive01.zip
(855.34 KiB) Downloaded 137 times
Fix
Newbie
Newbie
 
Posts: 4
Joined: Sat Dec 14, 2013 7:20 am

Re: ISR interrupt only firing once on PWM interrupt

Postby bobmarlowe » Sun Dec 15, 2013 4:10 am

You defined for Timer_PeriodCapture_Start to interrupt on FIFO full, not at capture which could be done unsing the capture_out signal as well. Since you do not read off any value from the timer the FIFO stays full and gets never cleared.


Bob
User avatar
bobmarlowe
The Big Cheese
The Big Cheese
 
Posts: 1490
Joined: Thu Oct 06, 2011 2:03 am
Location: Germany

Re: ISR interrupt only firing once on PWM interrupt

Postby Fix » Mon Dec 16, 2013 4:33 am

Hello

It's commented out now but in "Test:" in Switch/case in main() I did:

Code: Select all
               while(!interrupt_PeriodCapture);
               
                LCD_Char_1_Position(0, 0); // Set Row/Column
               
                vals[0] = Timer_PeriodCapture_ReadCapture();
                vals[1] = Timer_PeriodCapture_ReadCapture();
                vals[2] = Timer_PeriodCapture_ReadCapture();
                vals[3] = Timer_PeriodCapture_ReadCapture();
                   
                sprintf(buffer, "%ld, %ld", vals[0] - vals[1], vals[1] - vals[2]);
                LCD_Char_1_PrintString(buffer);
                .....
                interrupt_PeriodCapture=0;


thanks
Fix
Newbie
Newbie
 
Posts: 4
Joined: Sat Dec 14, 2013 7:20 am

Re: ISR interrupt only firing once on PWM interrupt

Postby Fix » Mon Dec 16, 2013 8:04 am

Hello

It seems 1. that the PWM resetted the timer on every capture and 2. that i have to manually call ClearFIFO().
Now it seems to work (Interrupt) but the whole doesn't work as I want anyway.
So finish for this Project, document it and good is.

thank you!
Fix
Newbie
Newbie
 
Posts: 4
Joined: Sat Dec 14, 2013 7:20 am


Return to “%s” PSoC Creator (PSoC3 & PSoC5 IDE)

Who is online

Users browsing this forum: No registered users and 1 guest