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
Solved! Go to Solution.
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
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,