1 /*
2 * Copyright 2018 NXP.
3 * All rights reserved.
4 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 */
7
8 /***********************************************************************************************************************
9 * This file was generated by the MCUXpresso Config Tools. Any manual edits made to this file
10 * will be overwritten if the respective MCUXpresso Config Tools is used to update this file.
11 **********************************************************************************************************************/
12 /*
13 * How to setup clock using clock driver functions:
14 *
15 * 1. call CLOCK_SetSimSafeDivs() to set the system clock dividers in SIM to safe value.
16 *
17 * 2. If external oscillator is used Call CLOCK_SetXtal0Freq() to set XTAL0 frequency based on board settings and
18 * call CLOCK_InitOsc0() to init the OSC.
19 *
20 * 3. Call CLOCK_BootToXxxMode()/CLOCK_SetXxxMode() to set ICS run at the target mode.
21 *
22 * 4. If ICSIRCLK is needed, call CLOCK_SetInternalRefClkConfig() to enable the clock.
23 *
24 * 5. call CLOCK_SetSimConfig() to configure the divider in sim.
25 */
26
27 /* clang-format off */
28 /* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
29 !!GlobalInfo
30 product: Clocks v4.1
31 processor: MKE06Z128xxx4
32 package_id: MKE06Z128VLK4
33 mcu_data: ksdk2_0
34 processor_version: 4.0.0
35 board: FRDM-KE06Z
36 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
37 /* clang-format on */
38
39 #include "clock_config.h"
40
41 /*******************************************************************************
42 * Definitions
43 ******************************************************************************/
44
45 /*******************************************************************************
46 * Variables
47 ******************************************************************************/
48 /* System clock frequency. */
49 extern uint32_t SystemCoreClock;
50
51 /*******************************************************************************
52 ************************ BOARD_InitBootClocks function ************************
53 ******************************************************************************/
BOARD_InitBootClocks(void)54 void BOARD_InitBootClocks(void)
55 {
56 BOARD_BootClockRUN();
57 }
58
59 /*******************************************************************************
60 ********************** Configuration BOARD_BootClockRUN ***********************
61 ******************************************************************************/
62 /* clang-format off */
63 /* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
64 !!Configuration
65 name: BOARD_BootClockRUN
66 called_from_default_init: true
67 outputs:
68 - {id: Bus_clock.outFreq, value: 20 MHz}
69 - {id: Core_clock.outFreq, value: 40 MHz}
70 - {id: Flash_clock.outFreq, value: 20 MHz}
71 - {id: ICSFF_clock.outFreq, value: 31.25 kHz}
72 - {id: ICSIR_clock.outFreq, value: 37.5 kHz}
73 - {id: LPO_clock.outFreq, value: 1 kHz}
74 - {id: OSCER_clock.outFreq, value: 8 MHz}
75 - {id: Plat_clock.outFreq, value: 40 MHz}
76 - {id: System_clock.outFreq, value: 40 MHz}
77 - {id: Timer_clock.outFreq, value: 40 MHz}
78 settings:
79 - {id: ICSMode, value: FEE}
80 - {id: ICS.BDIV.scale, value: '1', locked: true}
81 - {id: ICS.IREFS.sel, value: ICS.RDIV}
82 - {id: ICS.RDIV.scale, value: '256'}
83 - {id: ICS_C1_IRCLKEN_CFG, value: Enabled}
84 - {id: OSC_CR_OSCEN_CFG, value: Enabled}
85 - {id: OSC_CR_OSC_MODE_CFG, value: ModeOscLowPower}
86 - {id: OSC_CR_RANGE_CFG, value: High}
87 - {id: OSC_CR_RANGE_RDIV_CFG, value: High}
88 - {id: SIM.DIV2.scale, value: '2'}
89 sources:
90 - {id: OSC.OSC.outFreq, value: 8 MHz, enabled: true}
91 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
92 /* clang-format on */
93
94 /*******************************************************************************
95 * Variables for BOARD_BootClockRUN configuration
96 ******************************************************************************/
97 const ics_config_t icsConfig_BOARD_BootClockRUN = {
98 .icsMode = kICS_ModeFEE, /* FEE - FLL Engaged External */
99 .irClkEnableMode = kICS_IrclkEnable, /* ICSIRCLK enabled, ICSIRCLK disabled in STOP mode */
100 .bDiv = 0x0U, /* Bus clock divider: divided by 1 */
101 .rDiv = 0x3U, /* FLL external reference clock divider: divided by 256 */
102 };
103 const sim_clock_config_t simConfig_BOARD_BootClockRUN = {
104 .outDiv1 = 0x0U, /* DIV1 clock divider: divided by 1 */
105 .outDiv2 = 0x1U, /* DIV2 clock divider: divided by 2 */
106 .outDiv3 = 0x0U, /* DIV3 clock divider: divided by 1 */
107 .busClkPrescaler = 0x0U, /* bus clock optional prescaler */
108 };
109 const osc_config_t oscConfig_BOARD_BootClockRUN = {
110 .freq = 8000000U, /* Oscillator frequency: 8000000Hz */
111 .workMode = kOSC_ModeOscLowPower, /* Oscillator low power */
112 .enableMode = kOSC_Enable, /* Enable external reference clock, disable external reference clock in STOP mode */
113 };
114
115 /*******************************************************************************
116 * Code for BOARD_BootClockRUN configuration
117 ******************************************************************************/
BOARD_BootClockRUN(void)118 void BOARD_BootClockRUN(void)
119 {
120 /* Set the system clock dividers in SIM to safe value. */
121 CLOCK_SetSimSafeDivs();
122 /* Initializes OSC0 according to board configuration. */
123 CLOCK_InitOsc0(&oscConfig_BOARD_BootClockRUN);
124 CLOCK_SetXtal0Freq(oscConfig_BOARD_BootClockRUN.freq);
125 /* Set ICS to FEE mode. */
126 CLOCK_BootToFeeMode(icsConfig_BOARD_BootClockRUN.bDiv, icsConfig_BOARD_BootClockRUN.rDiv);
127 /* Configure the Internal Reference clock (ICSIRCLK). */
128 CLOCK_SetInternalRefClkConfig(icsConfig_BOARD_BootClockRUN.irClkEnableMode);
129 /* Set the clock configuration in SIM module. */
130 CLOCK_SetSimConfig(&simConfig_BOARD_BootClockRUN);
131 /* Set SystemCoreClock variable. */
132 SystemCoreClock = BOARD_BOOTCLOCKRUN_CORE_CLOCK;
133 }
134