I want to explain, that the global value g_Fro_Osc_Freq is setting the wrong SystemCoreClock value (called main clock in the chip user manual, too) :
In fsl_clock.c the required division by 2 happens correctly (user manual explains that the system clock/main clock is half of the value used for setting the free running oscillator clock, e.g. 30MHz FRO results into 15MHz main clock or system clock). g_Fro_Osc_Freq is the value to set the FRO. To update the SystemCoreClock value requires to divide g_Fro_Osc_Freq by 2. So I mean the SystemCoreClockUpdate has a bug.
/*! brief Return Frequency of FRO.
* return Frequency of FRO.
*/
uint32_t CLOCK_GetFroFreq(void)
{
return g_Fro_Osc_Freq / 2;
}
So the correct code should be finally in system_LCP802.c ... ...
void SystemCoreClockUpdate (void) {
switch (SYSCON->MAINCLKSEL & 0x03) {
case 0: /* Free running oscillator (FRO) */
SystemCoreClock = g_Fro_Osc_Freq / 2;
break;
case 1: /* System oscillator */
SystemCoreClock = CLK_OSC_IN;
break;
case 2: /* low power oscillator */
SystemCoreClock = CLK_OSC_LP;
break;
case 3: /* Free running oscillator (FRO) / 2 */
SystemCoreClock = (g_Fro_Osc_Freq >> 2); // or g_Fro_Osc_Freq / 4
break;
}
SystemCoreClock /= SYSCON->SYSAHBCLKDIV;
}
I only want to get the confirmation and if my meaning is correct somebody from NXP will fix this in the SDK (or fsl) :-)