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