1 /* 2 ** ################################################################### 3 ** Processors: MIMXRT595SFAWC_cm33 4 ** MIMXRT595SFFOC_cm33 5 ** 6 ** Compilers: GNU C Compiler 7 ** IAR ANSI C/C++ Compiler for ARM 8 ** Keil ARM C/C++ Compiler 9 ** MCUXpresso Compiler 10 ** 11 ** Reference manual: iMXRT500RM Rev.1, 07/2022 12 ** Version: rev. 5.0, 2020-08-27 13 ** Build: b231102 14 ** 15 ** Abstract: 16 ** Provides a system configuration function and a global variable that 17 ** contains the system frequency. It configures the device and initializes 18 ** the oscillator (PLL) that is part of the microcontroller device. 19 ** 20 ** Copyright 2016 Freescale Semiconductor, Inc. 21 ** Copyright 2016-2023 NXP 22 ** SPDX-License-Identifier: BSD-3-Clause 23 ** 24 ** http: www.nxp.com 25 ** mail: support@nxp.com 26 ** 27 ** Revisions: 28 ** - rev. 1.0 (2019-04-19) 29 ** Initial version. 30 ** - rev. 2.0 (2019-07-22) 31 ** Base on rev 0.7 RM. 32 ** - rev. 3.0 (2020-03-16) 33 ** Base on Rev.A RM. 34 ** - rev. 4.0 (2020-05-18) 35 ** Base on Rev.B RM. 36 ** - rev. 5.0 (2020-08-27) 37 ** Base on Rev.C RM. 38 ** 39 ** ################################################################### 40 */ 41 42 /*! 43 * @file MIMXRT595S_cm33 44 * @version 5.0 45 * @date 2020-08-27 46 * @brief Device specific configuration file for MIMXRT595S_cm33 (header file) 47 * 48 * Provides a system configuration function and a global variable that contains 49 * the system frequency. It configures the device and initializes the oscillator 50 * (PLL) that is part of the microcontroller device. 51 */ 52 53 #ifndef _SYSTEM_MIMXRT595S_cm33_H_ 54 #define _SYSTEM_MIMXRT595S_cm33_H_ /**< Symbol preventing repeated inclusion */ 55 56 #ifdef __cplusplus 57 extern "C" { 58 #endif 59 60 #include <stdint.h> 61 62 #define DEFAULT_SYSTEM_CLOCK 1000000u /* Default System clock value */ 63 #ifndef CLK_XTAL_OSC_CLK 64 #define CLK_XTAL_OSC_CLK 24000000u /* Default XTAL OSC clock */ 65 #endif 66 #define CLK_RTC_32K_CLK 32768u /* RTC oscillator 32 kHz (32k_clk) */ 67 #define CLK_LPOSC_1MHZ 1000000u /* Low power oscillator 1 MHz (1m_lposc) */ 68 #ifndef CLK_FRO_HIGH_FREQ 69 #define CLK_FRO_HIGH_FREQ 192000000u /* The high frequency of the FRO clock */ 70 #endif 71 #ifndef CLK_FRO_LOW_FREQ 72 #define CLK_FRO_LOW_FREQ 96000000u /* The low frequency of the FRO clock */ 73 #endif 74 #ifndef CLK_EXT_CLKIN 75 #define CLK_EXT_CLKIN 0u /* Default external CLKIN pin clock */ 76 #endif 77 #define CLK_OSC_CLK \ 78 ((CLKCTL0->SYSOSCBYPASS == 0u) ? CLK_XTAL_OSC_CLK : ((CLKCTL0->SYSOSCBYPASS == 1u) ? CLK_EXT_CLKIN : 0u)) 79 80 #define FRO_TUNER_USED ((CLKCTL0->FRO_CONTROL & CLKCTL0_FRO_CONTROL_EXP_COUNT_MASK) != 0u) 81 #define FRO_FREQ_GET_FROM_FUSE ((CLKCTL0->FRO_SCTRIM & 0x3fu) == 0x2fu ? CLK_FRO_LOW_FREQ : CLK_FRO_HIGH_FREQ) 82 /* freq = reference_clk * (2 * FRO_CAPVAL - 6) / 4095 */ 83 #define FRO_FREQ_GET_FROM_TUNER \ 84 (CLK_OSC_CLK / 4095u * (2u * (CLKCTL0->FRO_CAPVAL & CLKCTL0_FRO_CAPVAL_CAPVAL_MASK) - 6u) * 4u) 85 86 #define CLK_FRO_CLK (FRO_TUNER_USED ? FRO_FREQ_GET_FROM_TUNER : FRO_FREQ_GET_FROM_FUSE) 87 #define CLK_FRO_DIV2_CLK (CLK_FRO_CLK / 2u) /* FRO_DIV2 clock frequency */ 88 #define CLK_FRO_DIV4_CLK (CLK_FRO_CLK / 4u) /* FRO_DIV4 clock frequency */ 89 #define CLK_FRO_DIV8_CLK (CLK_FRO_CLK / 8u) /* FRO_DIV8 clock frequency */ 90 #define CLK_FRO_DIV16_CLK (CLK_FRO_CLK / 16u) /* FRO_DIV16 clock frequency */ 91 92 /** 93 * @brief System clock frequency (core clock) 94 * 95 * The system clock frequency supplied to the SysTick timer and the processor 96 * core clock. This variable can be used by the user application to setup the 97 * SysTick timer or configure other parameters. It may also be used by debugger to 98 * query the frequency of the debug timer or configure the trace clock speed 99 * SystemCoreClock is initialized with a correct predefined value. 100 */ 101 extern uint32_t SystemCoreClock; 102 103 /** 104 * @brief Setup the microcontroller system. 105 * 106 * Typically this function configures the oscillator (PLL) that is part of the 107 * microcontroller device. For systems with variable clock speed it also updates 108 * the variable SystemCoreClock. SystemInit is called from startup_device file. 109 */ 110 void SystemInit(void); 111 112 /** 113 * @brief Updates the SystemCoreClock variable. 114 * 115 * It must be called whenever the core clock is changed during program 116 * execution. SystemCoreClockUpdate() evaluates the clock register settings and calculates 117 * the current core clock. 118 */ 119 void SystemCoreClockUpdate(void); 120 121 /** 122 * @brief SystemInit function hook. 123 * 124 * This weak function allows to call specific initialization code during the 125 * SystemInit() execution.This can be used when an application specific code needs 126 * to be called as close to the reset entry as possible (for example the Multicore 127 * Manager MCMGR_EarlyInit() function call). 128 * NOTE: No global r/w variables can be used in this hook function because the 129 * initialization of these variables happens after this function. 130 */ 131 void SystemInitHook(void); 132 133 #ifdef __cplusplus 134 } 135 #endif 136 137 #endif /* _SYSTEM_MIMXRT595S_cm33_H_ */ 138