ISSDK  1.8
IoT Sensing Software Development Kit
clock_config.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015, Freescale Semiconductor, Inc.
3  * Copyright 2016-2017 NXP
4  * All rights reserved.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  */
8 
9 /*
10  * How to set up clock using clock driver functions:
11  *
12  * 1. Setup clock sources.
13  *
14  * 2. Setup voltage for the fastest of the clock outputs
15  *
16  * 3. Set up wait states of the flash.
17  *
18  * 4. Set up all dividers.
19  *
20  * 5. Set up all selectors to provide selected clocks.
21  */
22 
23 /* TEXT BELOW IS USED AS SETTING FOR THE CLOCKS TOOL *****************************
24 !!ClocksProfile
25 product: Clocks v1.0
26 processor: LPC54114J256
27 package_id: LPC54114J256BD64
28 mcu_data: ksdk2_0
29 processor_version: 1.1.0
30 board: LPCXpresso54114
31  * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR THE CLOCKS TOOL **/
32 
33 #include "fsl_power.h"
34 #include "fsl_clock.h"
35 #include "clock_config.h"
36 
37 /*******************************************************************************
38  * Definitions
39  ******************************************************************************/
40 
41 /*******************************************************************************
42  * Variables
43  ******************************************************************************/
44 /* System clock frequency. */
45 extern uint32_t SystemCoreClock;
46 
47 /*******************************************************************************
48  ********************* Configuration BOARD_BootClockFRO12M ***********************
49  ******************************************************************************/
50 /* TEXT BELOW IS USED AS SETTING FOR THE CLOCKS TOOL *****************************
51 !!Configuration
52 name: BOARD_BootClockFRO12M
53 outputs:
54 - {id: System_clock.outFreq, value: 12 MHz}
55  * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR THE CLOCKS TOOL **/
56 
57 /*******************************************************************************
58  * Variables for BOARD_BootClockFRO12M configuration
59  ******************************************************************************/
60 /*******************************************************************************
61  * Code for BOARD_BootClockFRO12M configuration
62  ******************************************************************************/
64 {
65  /*!< Set up the clock sources */
66  /*!< Set up FRO */
67  POWER_DisablePD(kPDRUNCFG_PD_FRO_EN); /*!< Ensure FRO is on */
68  CLOCK_AttachClk(kFRO12M_to_MAIN_CLK); /*!< Switch to FRO 12MHz first to ensure we can change voltage without accidentally
69  being below the voltage for current speed */
70  CLOCK_SetupFROClocking(12000000U); /*!< Set up FRO to the 12 MHz, just for sure */
71  POWER_SetVoltageForFreq(12000000U); /*!< Set voltage for the one of the fastest clock outputs: System clock output */
72  CLOCK_SetFLASHAccessCyclesForFreq(12000000U); /*!< Set FLASH wait states for core */
73 
74  /*!< Set up dividers */
75  CLOCK_SetClkDiv(kCLOCK_DivAhbClk, 1U, false); /*!< Set AHBCLKDIV divider to value 1 */
76 
77  /*!< Set up clock selectors - Attach clocks to the peripheries */
78  CLOCK_AttachClk(kFRO12M_to_MAIN_CLK); /*!< Switch MAIN_CLK to FRO12M */
79  /*!< Set SystemCoreClock variable. */
81 }
82 
83 /*******************************************************************************
84  ********************** Configuration BOARD_BootClockFROHF48M ***********************
85  ******************************************************************************/
86 /* TEXT BELOW IS USED AS SETTING FOR THE CLOCKS TOOL *****************************
87 !!Configuration
88 name: BOARD_BootClockFROHF48M
89 outputs:
90 - {id: System_clock.outFreq, value: 48 MHz}
91 settings:
92 - {id: SYSCON.MAINCLKSELA.sel, value: SYSCON.fro_hf}
93  * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR THE CLOCKS TOOL **/
94 
95 /*******************************************************************************
96  * Variables for BOARD_BootClockFROHF48M configuration
97  ******************************************************************************/
98 /*******************************************************************************
99  * Code for BOARD_BootClockFROHF48M configuration
100  ******************************************************************************/
102 {
103  /*!< Set up the clock sources */
104  /*!< Set up FRO */
105  POWER_DisablePD(kPDRUNCFG_PD_FRO_EN); /*!< Ensure FRO is on */
106  CLOCK_AttachClk(kFRO12M_to_MAIN_CLK); /*!< Switch to FRO 12MHz first to ensure we can change voltage without accidentally
107  being below the voltage for current speed */
108  POWER_SetVoltageForFreq(48000000U); /*!< Set voltage for the one of the fastest clock outputs: System clock output */
109  CLOCK_SetFLASHAccessCyclesForFreq(48000000U); /*!< Set FLASH wait states for core */
110 
111  CLOCK_SetupFROClocking(48000000U); /*!< Set up high frequency FRO output to selected frequency */
112 
113  /*!< Set up dividers */
114  CLOCK_SetClkDiv(kCLOCK_DivAhbClk, 1U, false); /*!< Set AHBCLKDIV divider to value 1 */
115 
116  /*!< Set up clock selectors - Attach clocks to the peripheries */
117  CLOCK_AttachClk(kFRO_HF_to_MAIN_CLK); /*!< Switch MAIN_CLK to FRO_HF */
118  /*!< Set SystemCoreClock variable. */
120 }
121 
122 /*******************************************************************************
123  ********************* Configuration BOARD_BootClockFROHF96M **********************
124  ******************************************************************************/
125 /* TEXT BELOW IS USED AS SETTING FOR THE CLOCKS TOOL *****************************
126 !!Configuration
127 name: BOARD_BootClockFROHF96M
128 outputs:
129 - {id: System_clock.outFreq, value: 96 MHz}
130 settings:
131 - {id: SYSCON.MAINCLKSELA.sel, value: SYSCON.fro_hf}
132 sources:
133 - {id: SYSCON.fro_hf.outFreq, value: 96 MHz}
134  * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR THE CLOCKS TOOL **/
135 
136 /*******************************************************************************
137  * Variables for BOARD_BootClockFROHF96M configuration
138  ******************************************************************************/
139 /*******************************************************************************
140  * Code for BOARD_BootClockFROHF96M configuration
141  ******************************************************************************/
143 {
144  /*!< Set up the clock sources */
145  /*!< Set up FRO */
146  POWER_DisablePD(kPDRUNCFG_PD_FRO_EN); /*!< Ensure FRO is on */
147  CLOCK_AttachClk(kFRO12M_to_MAIN_CLK); /*!< Switch to FRO 12MHz first to ensure we can change voltage without accidentally
148  being below the voltage for current speed */
149  POWER_SetVoltageForFreq(96000000U); /*!< Set voltage for the one of the fastest clock outputs: System clock output */
150  CLOCK_SetFLASHAccessCyclesForFreq(96000000U); /*!< Set FLASH wait states for core */
151 
152  CLOCK_SetupFROClocking(96000000U); /*!< Set up high frequency FRO output to selected frequency */
153 
154  /*!< Set up dividers */
155  CLOCK_SetClkDiv(kCLOCK_DivAhbClk, 1U, false); /*!< Set AHBCLKDIV divider to value 1 */
156 
157  /*!< Set up clock selectors - Attach clocks to the peripheries */
158  CLOCK_AttachClk(kFRO_HF_to_MAIN_CLK); /*!< Switch MAIN_CLK to FRO_HF */
159  /*!< Set SystemCoreClock variable. */
161 }
162 
#define BOARD_BOOTCLOCKFROHF48M_CORE_CLOCK
Definition: clock_config.h:53
#define BOARD_BOOTCLOCKFRO12M_CORE_CLOCK
Definition: clock_config.h:28
void BOARD_BootClockFRO12M(void)
This function executes configuration of clocks.
Definition: clock_config.c:63
#define BOARD_BOOTCLOCKFROHF96M_CORE_CLOCK
Definition: clock_config.h:78
void BOARD_BootClockFROHF48M(void)
This function executes configuration of clocks.
Definition: clock_config.c:101
void BOARD_BootClockFROHF96M(void)
This function executes configuration of clocks.
Definition: clock_config.c:142
uint32_t SystemCoreClock