ISSDK  1.7
IoT Sensing Software Development Kit
clock_config.c
Go to the documentation of this file.
1 /*
2  * The Clear BSD License
3  * Copyright (c) 2015, Freescale Semiconductor, Inc.
4  * Copyright 2016-2017 NXP
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without modification,
8  * are permitted (subject to the limitations in the disclaimer below) provided
9  * that the following conditions are met:
10  *
11  * o Redistributions of source code must retain the above copyright notice, this list
12  * of conditions and the following disclaimer.
13  *
14  * o Redistributions in binary form must reproduce the above copyright notice, this
15  * list of conditions and the following disclaimer in the documentation and/or
16  * other materials provided with the distribution.
17  *
18  * o Neither the name of the copyright holder nor the names of its
19  * contributors may be used to endorse or promote products derived from this
20  * software without specific prior written permission.
21  *
22  * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE.
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
27  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
30  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34 
35 /*
36  * How to setup clock using clock driver functions:
37  *
38  * 1. CLOCK_SetSimSafeDivs, to make sure core clock, bus clock, flexbus clock
39  * and flash clock are in allowed range during clock mode switch.
40  *
41  * 2. Call CLOCK_Osc0Init to setup OSC clock, if it is used in target mode.
42  *
43  * 3. Set MCG configuration, MCG includes three parts: FLL clock, PLL clock and
44  * internal reference clock(MCGIRCLK). Follow the steps to setup:
45  *
46  * 1). Call CLOCK_BootToXxxMode to set MCG to target mode.
47  *
48  * 2). If target mode is FBI/BLPI/PBI mode, the MCGIRCLK has been configured
49  * correctly. For other modes, need to call CLOCK_SetInternalRefClkConfig
50  * explicitly to setup MCGIRCLK.
51  *
52  * 3). Don't need to configure FLL explicitly, because if target mode is FLL
53  * mode, then FLL has been configured by the function CLOCK_BootToXxxMode,
54  * if the target mode is not FLL mode, the FLL is disabled.
55  *
56  * 4). If target mode is PEE/PBE/PEI/PBI mode, then the related PLL has been
57  * setup by CLOCK_BootToXxxMode. In FBE/FBI/FEE/FBE mode, the PLL could
58  * be enabled independently, call CLOCK_EnablePll0 explicitly in this case.
59  *
60  * 4. Call CLOCK_SetSimConfig to set the clock configuration in SIM.
61  */
62 
63 /* TEXT BELOW IS USED AS SETTING FOR THE CLOCKS TOOL *****************************
64 !!ClocksProfile
65 product: Clocks v1.0
66 processor: MK22FN512xxx12
67 package_id: MK22FN512VLH12
68 mcu_data: ksdk2_0
69 processor_version: 1.0.1
70  * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR THE CLOCKS TOOL **/
71 
72 #include "fsl_smc.h"
73 #include "clock_config.h"
74 
75 /*******************************************************************************
76  * Definitions
77  ******************************************************************************/
78 #define MCG_PLL_DISABLE 0U /*!< MCGPLLCLK disabled */
79 #define OSC_CAP0P 0U /*!< Oscillator 0pF capacitor load */
80 #define OSC_ER_CLK_DISABLE 0U /*!< Disable external reference clock */
81 #define SIM_OSC32KSEL_RTC32KCLK_CLK 2U /*!< OSC32KSEL select: RTC32KCLK clock (32.768kHz) */
82 #define SIM_PLLFLLSEL_IRC48MCLK_CLK 3U /*!< PLLFLL select: IRC48MCLK clock */
83 #define SIM_PLLFLLSEL_MCGPLLCLK_CLK 1U /*!< PLLFLL select: MCGPLLCLK clock */
84 
85 /*******************************************************************************
86  * Variables
87  ******************************************************************************/
88 /* System clock frequency. */
89 extern uint32_t SystemCoreClock;
90 
91 /*******************************************************************************
92  * Code
93  ******************************************************************************/
94 /*FUNCTION**********************************************************************
95  *
96  * Function Name : CLOCK_CONFIG_SetFllExtRefDiv
97  * Description : Configure FLL external reference divider (FRDIV).
98  * Param frdiv : The value to set FRDIV.
99  *
100  *END**************************************************************************/
101 static void CLOCK_CONFIG_SetFllExtRefDiv(uint8_t frdiv)
102 {
103  MCG->C1 = ((MCG->C1 & ~MCG_C1_FRDIV_MASK) | MCG_C1_FRDIV(frdiv));
104 }
105 
106 /*******************************************************************************
107  ********************** Configuration BOARD_BootClockRUN ***********************
108  ******************************************************************************/
109 /* TEXT BELOW IS USED AS SETTING FOR THE CLOCKS TOOL *****************************
110 !!Configuration
111 name: BOARD_BootClockRUN
112 outputs:
113 - {id: Bus_clock.outFreq, value: 40 MHz}
114 - {id: Core_clock.outFreq, value: 80 MHz}
115 - {id: Flash_clock.outFreq, value: 20 MHz}
116 - {id: FlexBus_clock.outFreq, value: 80/3 MHz}
117 - {id: LPO_clock.outFreq, value: 1 kHz}
118 - {id: MCGFFCLK.outFreq, value: 250 kHz}
119 - {id: MCGIRCLK.outFreq, value: 32.768 kHz}
120 - {id: OSCERCLK.outFreq, value: 8 MHz}
121 - {id: OSCERCLK_UNDIV.outFreq, value: 8 MHz}
122 - {id: PLLFLLCLK.outFreq, value: 80 MHz}
123 - {id: System_clock.outFreq, value: 80 MHz}
124 settings:
125 - {id: MCGMode, value: PEE}
126 - {id: MCG.FCRDIV.scale, value: '1', locked: true}
127 - {id: MCG.FRDIV.scale, value: '32'}
128 - {id: MCG.IREFS.sel, value: MCG.FRDIV}
129 - {id: MCG.PLLS.sel, value: MCG.PLL}
130 - {id: MCG.PRDIV.scale, value: '4', locked: true}
131 - {id: MCG.VDIV.scale, value: '40', locked: true}
132 - {id: MCG_C1_IRCLKEN_CFG, value: Enabled}
133 - {id: MCG_C2_OSC_MODE_CFG, value: ModeOscLowPower}
134 - {id: MCG_C2_RANGE0_CFG, value: Very_high}
135 - {id: MCG_C2_RANGE0_FRDIV_CFG, value: Very_high}
136 - {id: OSC_CR_ERCLKEN_CFG, value: Enabled}
137 - {id: OSC_CR_ERCLKEN_UNDIV_CFG, value: Enabled}
138 - {id: RTC_CR_OSCE_CFG, value: Enabled}
139 - {id: RTC_CR_OSC_CAP_LOAD_CFG, value: SC12PF}
140 - {id: SIM.LPUARTSRCSEL.sel, value: OSC.OSCERCLK}
141 - {id: SIM.OSC32KSEL.sel, value: RTC.RTC32KCLK}
142 - {id: SIM.OUTDIV2.scale, value: '2'}
143 - {id: SIM.OUTDIV3.scale, value: '3'}
144 - {id: SIM.OUTDIV4.scale, value: '4', locked: true}
145 - {id: SIM.PLLFLLSEL.sel, value: MCG.MCGPLLCLK}
146 sources:
147 - {id: OSC.OSC.outFreq, value: 8 MHz, enabled: true}
148  * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR THE CLOCKS TOOL **/
149 
150 /*******************************************************************************
151  * Variables for BOARD_BootClockRUN configuration
152  ******************************************************************************/
153 const mcg_config_t mcgConfig_BOARD_BootClockRUN =
154  {
155  .mcgMode = kMCG_ModePEE, /* PEE - PLL Engaged External */
156  .irclkEnableMode = kMCG_IrclkEnable, /* MCGIRCLK enabled, MCGIRCLK disabled in STOP mode */
157  .ircs = kMCG_IrcSlow, /* Slow internal reference clock selected */
158  .fcrdiv = 0x0U, /* Fast IRC divider: divided by 1 */
159  .frdiv = 0x0U, /* FLL reference clock divider: divided by 32 */
160  .drs = kMCG_DrsLow, /* Low frequency range */
161  .dmx32 = kMCG_Dmx32Default, /* DCO has a default range of 25% */
162  .oscsel = kMCG_OscselOsc, /* Selects System Oscillator (OSCCLK) */
163  .pll0Config =
164  {
165  .enableMode = MCG_PLL_DISABLE, /* MCGPLLCLK disabled */
166  .prdiv = 0x3U, /* PLL Reference divider: divided by 4 */
167  .vdiv = 0x10U, /* VCO divider: multiplied by 40 */
168  },
169  };
170 const sim_clock_config_t simConfig_BOARD_BootClockRUN =
171  {
172  .pllFllSel = SIM_PLLFLLSEL_MCGPLLCLK_CLK, /* PLLFLL select: MCGPLLCLK clock */
173  .er32kSrc = SIM_OSC32KSEL_RTC32KCLK_CLK, /* OSC32KSEL select: RTC32KCLK clock (32.768kHz) */
174  .clkdiv1 = 0x1230000U, /* SIM_CLKDIV1 - OUTDIV1: /1, OUTDIV2: /2, OUTDIV3: /3, OUTDIV4: /4 */
175  };
176 const osc_config_t oscConfig_BOARD_BootClockRUN =
177  {
178  .freq = 8000000U, /* Oscillator frequency: 8000000Hz */
179  .capLoad = (OSC_CAP0P), /* Oscillator capacity load: 0pF */
180  .workMode = kOSC_ModeOscLowPower, /* Oscillator low power */
181  .oscerConfig =
182  {
183  .enableMode = kOSC_ErClkEnable, /* Enable external reference clock, disable external reference clock in STOP mode */
184  .erclkDiv = 0, /* Divider for OSCERCLK: divided by 1 */
185  }
186  };
187 
188 /*******************************************************************************
189  * Code for BOARD_BootClockRUN configuration
190  ******************************************************************************/
192 {
193  /* Set the system clock dividers in SIM to safe value. */
194  CLOCK_SetSimSafeDivs();
195  /* Initializes OSC0 according to board configuration. */
196  CLOCK_InitOsc0(&oscConfig_BOARD_BootClockRUN);
197  CLOCK_SetXtal0Freq(oscConfig_BOARD_BootClockRUN.freq);
198  /* Configure the Internal Reference clock (MCGIRCLK). */
199  CLOCK_SetInternalRefClkConfig(mcgConfig_BOARD_BootClockRUN.irclkEnableMode,
202  /* Configure FLL external reference divider (FRDIV). */
203  CLOCK_CONFIG_SetFllExtRefDiv(mcgConfig_BOARD_BootClockRUN.frdiv);
204  /* Set MCG to PEE mode. */
205  CLOCK_BootToPeeMode(mcgConfig_BOARD_BootClockRUN.oscsel,
206  kMCG_PllClkSelPll0,
207  &mcgConfig_BOARD_BootClockRUN.pll0Config);
208  /* Set the clock configuration in SIM module. */
209  CLOCK_SetSimConfig(&simConfig_BOARD_BootClockRUN);
210  /* Set SystemCoreClock variable. */
212 }
213 
214 /*******************************************************************************
215  ********************* Configuration BOARD_BootClockVLPR ***********************
216  ******************************************************************************/
217 /* TEXT BELOW IS USED AS SETTING FOR THE CLOCKS TOOL *****************************
218 !!Configuration
219 name: BOARD_BootClockVLPR
220 outputs:
221 - {id: Bus_clock.outFreq, value: 4 MHz}
222 - {id: Core_clock.outFreq, value: 4 MHz}
223 - {id: Flash_clock.outFreq, value: 800 kHz}
224 - {id: FlexBus_clock.outFreq, value: 4 MHz}
225 - {id: LPO_clock.outFreq, value: 1 kHz}
226 - {id: MCGIRCLK.outFreq, value: 4 MHz}
227 - {id: System_clock.outFreq, value: 4 MHz}
228 settings:
229 - {id: MCGMode, value: BLPI}
230 - {id: powerMode, value: VLPR}
231 - {id: MCG.CLKS.sel, value: MCG.IRCS}
232 - {id: MCG.FCRDIV.scale, value: '1'}
233 - {id: MCG.FRDIV.scale, value: '32'}
234 - {id: MCG.IRCS.sel, value: MCG.FCRDIV}
235 - {id: MCG_C1_IRCLKEN_CFG, value: Enabled}
236 - {id: MCG_C2_OSC_MODE_CFG, value: ModeOscLowPower}
237 - {id: MCG_C2_RANGE0_CFG, value: Very_high}
238 - {id: MCG_C2_RANGE0_FRDIV_CFG, value: Very_high}
239 - {id: RTCCLKOUTConfig, value: 'yes'}
240 - {id: RTC_CR_OSCE_CFG, value: Enabled}
241 - {id: RTC_CR_OSC_CAP_LOAD_CFG, value: SC12PF}
242 - {id: SIM.OSC32KSEL.sel, value: RTC.RTC32KCLK}
243 - {id: SIM.OUTDIV3.scale, value: '1', locked: true}
244 - {id: SIM.OUTDIV4.scale, value: '5'}
245 - {id: SIM.PLLFLLSEL.sel, value: IRC48M.IRC48MCLK}
246 sources:
247 - {id: OSC.OSC.outFreq, value: 8 MHz}
248  * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR THE CLOCKS TOOL **/
249 
250 /*******************************************************************************
251  * Variables for BOARD_BootClockVLPR configuration
252  ******************************************************************************/
253 const mcg_config_t mcgConfig_BOARD_BootClockVLPR =
254  {
255  .mcgMode = kMCG_ModeBLPI, /* BLPI - Bypassed Low Power Internal */
256  .irclkEnableMode = kMCG_IrclkEnable, /* MCGIRCLK enabled, MCGIRCLK disabled in STOP mode */
257  .ircs = kMCG_IrcFast, /* Fast internal reference clock selected */
258  .fcrdiv = 0x0U, /* Fast IRC divider: divided by 1 */
259  .frdiv = 0x0U, /* FLL reference clock divider: divided by 32 */
260  .drs = kMCG_DrsLow, /* Low frequency range */
261  .dmx32 = kMCG_Dmx32Default, /* DCO has a default range of 25% */
262  .oscsel = kMCG_OscselOsc, /* Selects System Oscillator (OSCCLK) */
263  .pll0Config =
264  {
265  .enableMode = MCG_PLL_DISABLE, /* MCGPLLCLK disabled */
266  .prdiv = 0x0U, /* PLL Reference divider: divided by 1 */
267  .vdiv = 0x0U, /* VCO divider: multiplied by 24 */
268  },
269  };
270 const sim_clock_config_t simConfig_BOARD_BootClockVLPR =
271  {
272  .pllFllSel = SIM_PLLFLLSEL_IRC48MCLK_CLK, /* PLLFLL select: IRC48MCLK clock */
273  .er32kSrc = SIM_OSC32KSEL_RTC32KCLK_CLK, /* OSC32KSEL select: RTC32KCLK clock (32.768kHz) */
274  .clkdiv1 = 0x40000U, /* SIM_CLKDIV1 - OUTDIV1: /1, OUTDIV2: /1, OUTDIV3: /1, OUTDIV4: /5 */
275  };
276 const osc_config_t oscConfig_BOARD_BootClockVLPR =
277  {
278  .freq = 0U, /* Oscillator frequency: 0Hz */
279  .capLoad = (OSC_CAP0P), /* Oscillator capacity load: 0pF */
280  .workMode = kOSC_ModeOscLowPower, /* Oscillator low power */
281  .oscerConfig =
282  {
283  .enableMode = OSC_ER_CLK_DISABLE, /* Disable external reference clock */
284  .erclkDiv = 0, /* Divider for OSCERCLK: divided by 1 */
285  }
286  };
287 
288 /*******************************************************************************
289  * Code for BOARD_BootClockVLPR configuration
290  ******************************************************************************/
292 {
293  /* Set the system clock dividers in SIM to safe value. */
294  CLOCK_SetSimSafeDivs();
295  /* Set MCG to BLPI mode. */
296  CLOCK_BootToBlpiMode(mcgConfig_BOARD_BootClockVLPR.fcrdiv,
298  mcgConfig_BOARD_BootClockVLPR.irclkEnableMode);
299  /* Set the clock configuration in SIM module. */
300  CLOCK_SetSimConfig(&simConfig_BOARD_BootClockVLPR);
301  /* Set VLPR power mode. */
302  SMC_SetPowerModeProtection(SMC, kSMC_AllowPowerModeAll);
303 #if (defined(FSL_FEATURE_SMC_HAS_LPWUI) && FSL_FEATURE_SMC_HAS_LPWUI)
304  SMC_SetPowerModeVlpr(SMC, false);
305 #else
306  SMC_SetPowerModeVlpr(SMC);
307 #endif
308  while (SMC_GetPowerModeState(SMC) != kSMC_PowerStateVlpr)
309  {
310  }
311  /* Set SystemCoreClock variable. */
313 }
314 
315 /*******************************************************************************
316  ********************* Configuration BOARD_BootClockHSRUN **********************
317  ******************************************************************************/
318 /* TEXT BELOW IS USED AS SETTING FOR THE CLOCKS TOOL *****************************
319 !!Configuration
320 name: BOARD_BootClockHSRUN
321 outputs:
322 - {id: Bus_clock.outFreq, value: 60 MHz}
323 - {id: Core_clock.outFreq, value: 120 MHz}
324 - {id: Flash_clock.outFreq, value: 24 MHz}
325 - {id: FlexBus_clock.outFreq, value: 30 MHz}
326 - {id: LPO_clock.outFreq, value: 1 kHz}
327 - {id: MCGFFCLK.outFreq, value: 250 kHz}
328 - {id: MCGIRCLK.outFreq, value: 32.768 kHz}
329 - {id: OSCERCLK.outFreq, value: 8 MHz}
330 - {id: OSCERCLK_UNDIV.outFreq, value: 8 MHz}
331 - {id: PLLFLLCLK.outFreq, value: 120 MHz}
332 - {id: System_clock.outFreq, value: 120 MHz}
333 settings:
334 - {id: MCGMode, value: PEE}
335 - {id: powerMode, value: HSRUN}
336 - {id: MCG.FCRDIV.scale, value: '1', locked: true}
337 - {id: MCG.FRDIV.scale, value: '32'}
338 - {id: MCG.IREFS.sel, value: MCG.FRDIV}
339 - {id: MCG.PLLS.sel, value: MCG.PLL}
340 - {id: MCG.PRDIV.scale, value: '2', locked: true}
341 - {id: MCG.VDIV.scale, value: '30', locked: true}
342 - {id: MCG_C1_IRCLKEN_CFG, value: Enabled}
343 - {id: MCG_C2_OSC_MODE_CFG, value: ModeOscLowPower}
344 - {id: MCG_C2_RANGE0_CFG, value: Very_high}
345 - {id: MCG_C2_RANGE0_FRDIV_CFG, value: Very_high}
346 - {id: OSC_CR_ERCLKEN_CFG, value: Enabled}
347 - {id: OSC_CR_ERCLKEN_UNDIV_CFG, value: Enabled}
348 - {id: RTC_CR_OSCE_CFG, value: Enabled}
349 - {id: RTC_CR_OSC_CAP_LOAD_CFG, value: SC12PF}
350 - {id: SIM.LPUARTSRCSEL.sel, value: OSC.OSCERCLK}
351 - {id: SIM.OSC32KSEL.sel, value: RTC.RTC32KCLK}
352 - {id: SIM.OUTDIV2.scale, value: '2'}
353 - {id: SIM.OUTDIV3.scale, value: '4'}
354 - {id: SIM.OUTDIV4.scale, value: '5'}
355 - {id: SIM.PLLFLLSEL.sel, value: MCG.MCGPLLCLK}
356 - {id: SIM.RTCCLKOUTSEL.sel, value: RTC.RTC32KCLK}
357 - {id: SIM.USBDIV.scale, value: '5'}
358 - {id: SIM.USBFRAC.scale, value: '2'}
359 - {id: SIM.USBSRCSEL.sel, value: SIM.USBDIV}
360 sources:
361 - {id: OSC.OSC.outFreq, value: 8 MHz, enabled: true}
362  * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR THE CLOCKS TOOL **/
363 
364 /*******************************************************************************
365  * Variables for BOARD_BootClockHSRUN configuration
366  ******************************************************************************/
367 const mcg_config_t mcgConfig_BOARD_BootClockHSRUN =
368  {
369  .mcgMode = kMCG_ModePEE, /* PEE - PLL Engaged External */
370  .irclkEnableMode = kMCG_IrclkEnable, /* MCGIRCLK enabled, MCGIRCLK disabled in STOP mode */
371  .ircs = kMCG_IrcSlow, /* Slow internal reference clock selected */
372  .fcrdiv = 0x0U, /* Fast IRC divider: divided by 1 */
373  .frdiv = 0x0U, /* FLL reference clock divider: divided by 32 */
374  .drs = kMCG_DrsLow, /* Low frequency range */
375  .dmx32 = kMCG_Dmx32Default, /* DCO has a default range of 25% */
376  .oscsel = kMCG_OscselOsc, /* Selects System Oscillator (OSCCLK) */
377  .pll0Config =
378  {
379  .enableMode = MCG_PLL_DISABLE, /* MCGPLLCLK disabled */
380  .prdiv = 0x1U, /* PLL Reference divider: divided by 2 */
381  .vdiv = 0x6U, /* VCO divider: multiplied by 30 */
382  },
383  };
384 const sim_clock_config_t simConfig_BOARD_BootClockHSRUN =
385  {
386  .pllFllSel = SIM_PLLFLLSEL_MCGPLLCLK_CLK, /* PLLFLL select: MCGPLLCLK clock */
387  .er32kSrc = SIM_OSC32KSEL_RTC32KCLK_CLK, /* OSC32KSEL select: RTC32KCLK clock (32.768kHz) */
388  .clkdiv1 = 0x1340000U, /* SIM_CLKDIV1 - OUTDIV1: /1, OUTDIV2: /2, OUTDIV3: /4, OUTDIV4: /5 */
389  };
390 const osc_config_t oscConfig_BOARD_BootClockHSRUN =
391  {
392  .freq = 8000000U, /* Oscillator frequency: 8000000Hz */
393  .capLoad = (OSC_CAP0P), /* Oscillator capacity load: 0pF */
394  .workMode = kOSC_ModeOscLowPower, /* Oscillator low power */
395  .oscerConfig =
396  {
397  .enableMode = kOSC_ErClkEnable, /* Enable external reference clock, disable external reference clock in STOP mode */
398  .erclkDiv = 0, /* Divider for OSCERCLK: divided by 1 */
399  }
400  };
401 
402 /*******************************************************************************
403  * Code for BOARD_BootClockHSRUN configuration
404  ******************************************************************************/
406 {
407  /* Set HSRUN power mode */
408  SMC_SetPowerModeProtection(SMC, kSMC_AllowPowerModeAll);
409  SMC_SetPowerModeHsrun(SMC);
410  while (SMC_GetPowerModeState(SMC) != kSMC_PowerStateHsrun)
411  {
412  }
413  /* Set the system clock dividers in SIM to safe value. */
414  CLOCK_SetSimSafeDivs();
415  /* Initializes OSC0 according to board configuration. */
416  CLOCK_InitOsc0(&oscConfig_BOARD_BootClockHSRUN);
417  CLOCK_SetXtal0Freq(oscConfig_BOARD_BootClockHSRUN.freq);
418  /* Configure the Internal Reference clock (MCGIRCLK). */
419  CLOCK_SetInternalRefClkConfig(mcgConfig_BOARD_BootClockHSRUN.irclkEnableMode,
422  /* Configure FLL external reference divider (FRDIV). */
423  CLOCK_CONFIG_SetFllExtRefDiv(mcgConfig_BOARD_BootClockHSRUN.frdiv);
424  /* Set MCG to PEE mode. */
425  CLOCK_BootToPeeMode(mcgConfig_BOARD_BootClockHSRUN.oscsel,
426  kMCG_PllClkSelPll0,
427  &mcgConfig_BOARD_BootClockHSRUN.pll0Config);
428  /* Set the clock configuration in SIM module. */
429  CLOCK_SetSimConfig(&simConfig_BOARD_BootClockHSRUN);
430  /* Set SystemCoreClock variable. */
432 }
433 
void BOARD_BootClockRUN(void)
This function executes configuration of clocks.
Definition: clock_config.c:194
#define SIM_OSC32KSEL_RTC32KCLK_CLK
Definition: clock_config.c:81
const sim_clock_config_t simConfig_BOARD_BootClockVLPR
SIM module set for BOARD_BootClockVLPR configuration.
Definition: clock_config.c:272
const osc_config_t oscConfig_BOARD_BootClockRUN
OSC set for BOARD_BootClockRUN configuration.
Definition: clock_config.c:180
#define SIM_PLLFLLSEL_MCGPLLCLK_CLK
Definition: clock_config.c:83
#define OSC_ER_CLK_DISABLE
Definition: clock_config.c:80
void BOARD_BootClockHSRUN(void)
This function executes configuration of clocks.
Definition: clock_config.c:405
const osc_config_t oscConfig_BOARD_BootClockVLPR
OSC set for BOARD_BootClockVLPR configuration.
Definition: clock_config.c:278
const mcg_config_t mcgConfig_BOARD_BootClockRUN
MCG set for BOARD_BootClockRUN configuration.
Definition: clock_config.c:157
#define SIM_PLLFLLSEL_IRC48MCLK_CLK
Definition: clock_config.c:82
void BOARD_BootClockVLPR(void)
This function executes configuration of clocks.
Definition: clock_config.c:292
const mcg_config_t mcgConfig_BOARD_BootClockHSRUN
MCG set for BOARD_BootClockHSRUN configuration.
Definition: clock_config.c:367
#define BOARD_BOOTCLOCKVLPR_CORE_CLOCK
Definition: clock_config.h:86
const mcg_config_t mcgConfig_BOARD_BootClockVLPR
MCG set for BOARD_BootClockVLPR configuration.
Definition: clock_config.c:255
#define BOARD_BOOTCLOCKRUN_CORE_CLOCK
Definition: clock_config.h:51
uint32_t SystemCoreClock
const sim_clock_config_t simConfig_BOARD_BootClockHSRUN
SIM module set for BOARD_BootClockHSRUN configuration.
Definition: clock_config.c:384
const osc_config_t oscConfig_BOARD_BootClockHSRUN
OSC set for BOARD_BootClockHSRUN configuration.
Definition: clock_config.c:390
#define SMC
Definition: lpc54114.h:144
#define MCG_PLL_DISABLE
Definition: clock_config.c:78
const sim_clock_config_t simConfig_BOARD_BootClockRUN
SIM module set for BOARD_BootClockRUN configuration.
Definition: clock_config.c:174
#define BOARD_BOOTCLOCKHSRUN_CORE_CLOCK
Definition: clock_config.h:121
#define OSC_CAP0P
Definition: clock_config.c:79