/*! * @brief Main function */ int main(void) { volatile uint32_t i; uint32_t sysFreq; /* Structure for OSC configuration */ osc_config_t oscConfig; oscConfig.freq = BOARD_XTAL0_CLK_HZ; oscConfig.capLoad = 0U; oscConfig.workMode = kOSC_ModeOscLowPower; oscConfig.oscerConfig.enableMode = kOSC_ErClkEnable; BOARD_InitPins(); CLOCK_InitOsc0(&oscConfig); CLOCK_SetXtal0Freq(BOARD_XTAL0_CLK_HZ); /* Set clock divider to safe value to switch mode */ CLOCK_SetSimSafeDivs(); #if (defined(FSL_FEATURE_MCG_HAS_PLL_INTERNAL_MODE) && FSL_FEATURE_MCG_HAS_PLL_INTERNAL_MODE) /* Calculate frdiv */ if (!APP_GetAvailableFrdiv()) { while (1) { } } #endif /* FSL_FEATURE_MCG_HAS_PLL_INTERNAL_MODE || FSL_FEATURE_MCG_USE_PLLREFSEL */ /* Configure pll */ if (!APP_GetAvailablePllConfig(&g_pllConfig)) { while (1) { } } APP_BootToPeeExample(); /* Change clock PEE -> PBE -> BLPE */ APP_ChangePeeToBlpeExample(); /* Change clock BLPE -> PBE -> PEE */ APP_ChangeBlpeToPeeExample(); /* Get System clock to blink a LED */ sysFreq = CLOCK_GetFreq(kCLOCK_CoreSysClk) / 20U; /* Enable a LED */ LED_INIT(); /* Blink a LED */ while (1) { for (i = 0; i < sysFreq; i++) { __NOP(); } LED_TOGGLE(); } }
/*! * @brief Main function */ int main(void) { volatile uint32_t i; uint32_t sysFreq; /* Structure for OSC configuration */ osc_config_t oscConfig; oscConfig.freq = BOARD_XTAL0_CLK_HZ; oscConfig.capLoad = 0U; oscConfig.workMode = kOSC_ModeOscLowPower; oscConfig.oscerConfig.enableMode = kOSC_ErClkEnable; BOARD_InitPins(); CLOCK_InitOsc0(&oscConfig); CLOCK_SetXtal0Freq(BOARD_XTAL0_CLK_HZ); /* Set clock divider to safe value to switch mode */ CLOCK_SetSimSafeDivs(); /* Calculate frdiv */ if (!APP_GetAvailableFrdiv()) { while (1) { } } /* Boot to Fee mode */ APP_BootToFeeExample(); /* Change clock FEE -> FBE -> BLPE */ APP_ChangeFeeToBlpeExample(); /* Change clock BLPE -> FBE -> FEE */ APP_ChangeBlpeToFeeExample(); /* Get System clock to blink a LED */ sysFreq = CLOCK_GetFreq(kCLOCK_CoreSysClk) / 20U; /* Enable a LED */ LED_INIT(); /* Blink a LED */ while (1) { for (i = 0; i < sysFreq; i++) { __NOP(); } LED_TOGGLE(); } }