AnsweredAssumed Answered

FlexPWM Val Compare Interrupt Service Routine

Question asked by duanemattern on Nov 3, 2016

I want to use FlexPWM on the TRK-MPC5604P board to trigger an analog sampling.  I'll eventually use the cross triggering unit (CTU), but it has been giving me headaches to figure it out, so I thought I'd try something easier, just to get something running.  I'd thought I'd just use an interrupt service routine on Val(n) matches.  I've setup FLEXPWM0 on Module 2 and I can observe the A&B wavforms, (centerlined), and I can change the dutycycle on the fly from a serial interface.  So the FLEXPWM_0.SUB[2].VAL[i].R are all setup properly and working.


I enabled the interrupts for ALL (trying to see anything), of the VAL matches AND reload using 

FLEXPWM_0.SUB[2].INTEN.R = 0x103F;


I added the interrupt functions to the vector table

uint32_t IntcIsrVectorTable[] = {


   (uint32_t)&PWM0_RF2_ISR, /* Vector - 185 Reload Module2 */
   (uint32_t)&PWM0_COF2_ISR, /* Vector - 186 Compare Module2 */


and I added the interrupt service routines, and enabled the external interrupts using ( asm(" wrteei 1"); )   This also includes a period interrupt timer PIT.  After compiling, I can debug this on the target using CodeWarrior for MCU (V10.6 Eclipse).  I can set a breakpoint in the PIT interrupt service routine and break on the interrupt.  But I cannot break in either of the two PWM0 interrupts service routines.  It's as if the interrupts are never generated.


So my questions are:

1) , besides enabling external interrupts using asm(" wrteei 1"); is there something else that I must do to enable the PWM VAL matching/compare interrupts?

2)   The original demo code had source code for the period interrupt timer that did not include "#pragma interrupt on".  Is this a compiler directive that I need for the interrupt service routine to get a "return from interrupt" ?