Problem for PIT of MPC5744P

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

Problem for PIT of MPC5744P

Jump to solution
953 Views
nathan_
Contributor IV

I want to use the PIT module of MPC5744P.

The project is attached.

The relevant configuration of PIT is as follows:

 

 MC_CGM.AC3_SC.B.SELCTL = 0x01;    //connect XOSC to the PLL0 input 

 

// Set PLL0 to 200 MHz with 40MHz XOSC reference
PLLDIG.PLL0DV.R = 0x3002100A; // PREDIV = 1, MFD = 10, RFDPHI = 2, RFDPHI1 = 6

 

MC_CGM.SC_DC0.R = 0x80030000;    // PBRIDGE0/PBRIDGE1_CLK at syst clk div by 4(50 MHz)

 

After the configuration, the clock for PIT I think is 50MHz. And then, the code for PIT is as follows: 

 

PIT_0.TIMER[0].LDVAL.R = 50000000-1;   // setup timer 0 for 1sec period

 

But when I try to debug the project, it turns out that the period of PIT is 2 sec.

 

 Is there any mistakes in my configuration? Or some other problems I did not notice?

 

Thank you.

Original Attachment has been moved to: work9_29_1.rar

1 Solution
797 Views
petervlna
NXP TechSupport
NXP TechSupport

Hi,

I take it back.

I have tested your example and i can see 1s PIT timeout with LDVAL= 50 000 000.

Peter

View solution in original post

0 Kudos
7 Replies
798 Views
petervlna
NXP TechSupport
NXP TechSupport

Hi,

I take it back.

I have tested your example and i can see 1s PIT timeout with LDVAL= 50 000 000.

Peter

0 Kudos
797 Views
nathan_
Contributor IV

And the number of variable "counter" in the func is 10 after 20sec according to my watch.

0 Kudos
797 Views
nathan_
Contributor IV

I put an LED on the PA0 port, and according to the following code in my project:

void PIT0_Isr(void)
{
counter++;
counter2++;
SIUL2.GPDO[PA0].R = ~SIUL2.GPDO[PA0].R ; ////PA[0] GPIO - LED
PIT_0.TIMER[0].TFLG.B.TIF = 1; // Clear PIT_0 interrupt flag
}

The LED should be on and off after every PIT period.

I notice that the time for the LED to be on and off for 2 sec.

Why is  that?

0 Kudos
797 Views
petervlna
NXP TechSupport
NXP TechSupport

Check the PA0 pin level change on scope.

Do not measure period. You will get 2x change state change to create period.

pastedImage_1.png

Peter

797 Views
nathan_
Contributor IV

I made a little change in my previous code:

The value of PIT_0.TIMER[0].LDVAL.R is set to 50000-1 in order to measure the output with oscilloscope as follows:

   PIT_0.TIMER[0].LDVAL.R = 50000-1;   

which means the period of PIT is set to 1ms with 50MHz clock according to my configuration.

I have checked the output of PA0, and the output of PA0 is as follows:

PA0 output.jpg

As is shown in the picture, the frequency of the output is 250Hz, which means the period of the PA0 is 4ms and the 

PA0 is off for 2ms and then on for 2ms, which means that the PIT is executed every 2ms.

I do not know how to explain this.

Could you give me some advice or your opinion? Thanks a lot.

0 Kudos
797 Views
nathan_
Contributor IV

The LED should be off for 2sec and then on for 2sec and then off for 2sec, so the period is actually 4sec.

And the variable "counter" also shows that.

0 Kudos
797 Views
nathan_
Contributor IV

So what is the time between the  two executive times of PIT0_Isr function?

0 Kudos