Hi,
According to the MPC5744 reference manual ( Rev. 5, 04/2014 ):
I am using CMU_0 for the IRCOSC measurement and the reference clock is the XOSC.
When I write the value 0x64 in CMU_MDR[MD] register, I get the correct frequency which is, as per the above formula, 16 MHz given that the XOSC frequency is 40MHz.
When I write any other value in CMU_MDR[MD] register, I get incorrect values of the IRCOSC frequency. Do you have any explanation for this ?
Note: Also according to the reference manual,
MDR field is R/W and from my understanding we write into this register the number of clock cycles during which IROSC frequency measurement is done. Is that correct ?
Hi,
If you changed the MD, what is then a FD value you read after measurement is finished?
The MD specifies a number of IRC clock cycles to be measured.
The FD is loaded with number of XOSC clock cycles counted during measurement period.
BR, Petr
Hi Petr,
Thanks for your response.
The FD value that I read after measurement was a normal value in the debugger.
I guess the problem was not waiting enough time for the measurement to be finished successfully and it was resolved.
I have another question regarding the setting CMU_CSR register, as per the manual:
CMU_CSR[CKSEL1] values 00 and 11, do both values select CLKMT0_RMN ?
Thanks in advance,
Best Regards,
As per my testing the IRC is always measured regardless of CKSEL1 setting.
I was using this code
float IRC_measure(void)
{
float IRC;
uint32_t measDur = 50000; /* 0 – 1 048 575 */
CMU_0.CSR.B.CKSEL1 = 0; /* Measure IRC */
CMU_0.MDR.R = measDur;
CMU_0.CSR.B.SFM = 1;
while(CMU_0.CSR.B.SFM==1){};
IRC = (float)((40.0 * measDur) / CMU_0.FDR.R);
return IRC;
}
BR, Petr