MPC5744P PIT Interrupt problem

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

MPC5744P PIT Interrupt problem

3,079 Views
admin
Specialist II

Original Content posted by David Chung.

 

I'm writing a simple project for Panther that uses the PIT0 ISR to to toggle a GPIO pin. I use the 160MHz PLL as the clock source, initialize PIT0, enable PIT0 interrupts in the NVIC, add the PIT0_ISR address to the interrupt table. In the ISR, I clear the interrupt flag and toggle the GPIO pin.  The problem is for some reason the program only enters the ISR around 2 to 4 times before never entering again.  I can see that PIT_0.TFLG0 is set so an interrupt is called by PIT0, but it's not being handled. The PIT0 init code is shown:

 

void PIT0_init(uint32_t LDVAL) {

  volatile uint32_t dummy = 0;

  PIT_0.TIMER[0].LDVAL.R = LDVAL; /* Load # PIT clocks to count */

  PIT_0.TIMER[0].TCTRL.B.TIE = 1; /* Enable interrupt */

  INTC_0.PSR[226].B.PRIN = 10; /* IRQ priority = 10 (31 highest) */

  dummy = INTC_0.PSR[226].R;

  PIT_0.TIMER[0].TCTRL.B.TEN = 1; /* enable channel */

}

 

The ISR is as follows:

void PIT0_isr(void) {

  LED1 = ~LED1;             /* Toggle LED1 port */

   PIT_0.TIMER[0].TFLG.R |= 1;  /* Clear interrupt flag. w1c */

}

 

Anyone know the cause of this issue?

Labels (1)
6 Replies

2,472 Views
martin_kovar
NXP Employee
NXP Employee

Hi David,

look at this example. There is shown how to set PIT.

Example MPC5744P PinToggleStationery S32DS

At the first sight, you did not correctly configure INTC_0.PSR register. You only set priority, but you did not choose the core, which will handle the interrupt.

Regards,

Martin

0 Kudos

2,471 Views
nathan_
Contributor IV

Hello,I just download the example you uploaded and tried to debug it.

I want to use the PIT module, so I made a little change in the code. My project is attached.

I met a problem when I debug it. After I press the "resume", the code will fall into a function named "dummy" and do not go on, The picture is also attached, named "dummy"

Then I set a breakpoint before the while loop, I find out the code goes well before the while loop, which means in the initiation the problem did not occur.

Could you please help me to fix the problem? I really need to work out this problem and use the PIT module.

Thank you. 

0 Kudos

2,471 Views
martin_kovar
NXP Employee
NXP Employee

Hello Nathan,

you do not have installed correct interrupt service routine. Please see intc_SW_mode_isr_vectors_MPC5744P.c file in my project and add the interrupt service routine at correct address (Vector 226).

Regards,

Martin

0 Kudos

2,471 Views
nathan_
Contributor IV

I can not understand the set for PLL0 in the example.

According to the MPC5744P datasheet, the max of PLL0_PHI0 is 200MHz, but the example the PLL0 is set to 400MHz by the following code:

PLLDIG.PLL0DV.R = 0x58021014;     // PREDIV =  1, MFD = 20, RFDPHI = 2, RFDPHI1 = 11

Is this correct?

0 Kudos

2,471 Views
martin_kovar
NXP Employee
NXP Employee

Hello,

the calculation seems to be incorrect. Correct value for 200MHz with 40MHz crystal is:

PLLDIG.PLL0DV.R = 0x3002100A // PREDIV =  1, MFD = 10, RFDPHI = 2, RFDPHI1 = 6

Regards,

Martin

2,471 Views
nathan_
Contributor IV

The problem has been solved. Thank you so much !

0 Kudos