added prescaler for 16 bit pwm in LPC1347 target

Fork of mbed-dev by mbed official

Files at this revision

API Documentation at this revision

Comitter:
mbed_official
Date:
Thu Mar 24 06:30:11 2016 +0000
Parent:
96:12647ac05603
Child:
98:f043b034eb5d
Commit message:
Synchronized with git revision dd3cba536fbbd4e36a7e93fde54c3d3984bdd0f6

Full URL: https://github.com/mbedmicro/mbed/commit/dd3cba536fbbd4e36a7e93fde54c3d3984bdd0f6/

Prevent KL05 from using an unstable clock

Changed in this revision

targets/cmsis/TARGET_Freescale/TARGET_KLXX/TARGET_KL05Z/system_MKL05Z4.c Show annotated file Show diff for this revision Revisions of this file
--- a/targets/cmsis/TARGET_Freescale/TARGET_KLXX/TARGET_KL05Z/system_MKL05Z4.c	Thu Mar 24 06:15:10 2016 +0000
+++ b/targets/cmsis/TARGET_Freescale/TARGET_KLXX/TARGET_KL05Z/system_MKL05Z4.c	Thu Mar 24 06:30:11 2016 +0000
@@ -103,6 +103,11 @@
    -- 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 */
@@ -189,6 +194,13 @@
   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);
 }
 
 /* ----------------------------------------------------------------------------