MPC5674F PIT not trigerring interrupt

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MPC5674F PIT not trigerring interrupt

Jump to solution
1,097 Views
vincentbergeron
Contributor I

Hello,

 

I am trying to configure the PIT timer in order to trig an interrupt.  I am using the InctInterrupt.h and InctInterrupt.c from the Code Warrior 10.6.  Here is a sniplet of code to init pit and add a function to the interrupt vector:

 

initPit(){

     PIT.MCR.R = 0x00000001;               // Enable pit and freeze during debug

     PIT.CH[1].LDVAL = 40000000;        // 1 second interrupt for 40 MHz clock

     PIT.CH[1].TCRL.R = 0x00000003;  // Start timer

}

 

INTCInterruptFn pitIntFnct(){

     SIU.GDPO[PIN_NUMBER].R = !SIU.GDPO[PIN_NUMBER].R;  // Toggle pin

     PIT.CH[1].TFLG.B.TIF = 1;  // Reset interrupt flag

}

 

int main(){

     initPIT();

     INTC_InitINTCInterrupts();

     INTC_InstallINTCInterruptHandler(pitIntFnct(), 302, 1);    // PIT[1] is on vector number 302.  Priority 1.

     while(1){

    

     }

}

 

For some reason, the funtion is not trigerred when the PIT[1] flag is set to 1.  Do you have any idea why???

 

Regards

Labels (1)
0 Kudos
1 Solution
776 Views
PetrS
NXP TechSupport
NXP TechSupport

Try attached example. Is that also not working for you?


BR,

Petr

View solution in original post

0 Kudos
3 Replies
776 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

Install interrupt handler in this way…

INTC_InstallINTCInterruptHandler((INTCInterruptFn)pitIntFnct,304,1); /* vector304 for PIT3 */

For your case the “pitIntFnct” is called first and then wrong address is placed to the vector table.

Also do not call INTC_InitINTCInterrupts() explicitly, it is already called from user_init(); see e.g. MPC5674F_init_ram.c.

Regards,

Petr

776 Views
vincentbergeron
Contributor I

Thanks,

I am able to see in memory that the correct address is set.  However, the interrupt is triggerred only once and then , the INTC_CPR is not resetted to 0 (initial value).  The value 1 stays in the register and I think once the second interrupt is generated (after 2 seconds), the intc doesn't acknowledge it since it has the same priority as in the INTC_CPR register.  When writing 0 to INTC_EOIR register, doesn't it supposed to pop from LIFO the previous interrupt INTC_CPR value ????

regards,

0 Kudos
777 Views
PetrS
NXP TechSupport
NXP TechSupport

Try attached example. Is that also not working for you?


BR,

Petr

0 Kudos