Skip to content

Prevent KL05 from using an unstable clock #1622

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 24, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ uint32_t SystemCoreClock = DEFAULT_SYSTEM_CLOCK;
-- SystemInit()
---------------------------------------------------------------------------- */

static void busy_delay(uint32_t delay) {
volatile uint32_t i = delay;
while (i--);
}

void SystemInit (void) {
#if (DISABLE_WDOG)
/* Disable the WDOG module */
Expand Down Expand Up @@ -189,6 +194,13 @@ void SystemInit (void) {
while((MCG->S & MCG_S_IRCST_MASK) == 0x00U) { /* Check that the fast external reference clock is selected. */
}
#endif /* (CLOCK_SETUP == 2) */
// Give the FLL time to stabilize
// This can take up to 1ms according to the KL05 datasheet
// Note: Without this delay the UART's baud can be wrong for the
// first byte sent in some cases. A delay of 1000 fixes this
// problem even under optimizations. The delay of 10,000 is used
// to add a saftey margin.
busy_delay(10000);
}

/* ----------------------------------------------------------------------------
Expand Down