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.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?
Original Attachment has been moved to: work9_29_1.rar
Solved! Go to Solution.
I put an LED on the PA0 port, and according to the following code in my project:
SIUL2.GPDO[PA0].R = ~SIUL2.GPDO[PA0].R ; ////PA GPIO - LED
PIT_0.TIMER.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?
I made a little change in my previous code:
The value of PIT_0.TIMER.LDVAL.R is set to 50000-1 in order to measure the output with oscilloscope as follows:
PIT_0.TIMER.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:
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.