1 /* 2 ** ################################################################### 3 ** Processor: MKW24D512VHA5 4 ** Compilers: Keil ARM C/C++ Compiler 5 ** Freescale C/C++ for Embedded ARM 6 ** GNU C Compiler 7 ** IAR ANSI C/C++ Compiler for ARM 8 ** MCUXpresso Compiler 9 ** 10 ** Reference manual: MKW2xDRM Rev.2 July 2014 11 ** Version: rev. 2.0, 2014-11-26 12 ** Build: b170112 13 ** 14 ** Abstract: 15 ** Provides a system configuration function and a global variable that 16 ** contains the system frequency. It configures the device and initializes 17 ** the oscillator (PLL) that is part of the microcontroller device. 18 ** 19 ** Copyright (c) 2016 Freescale Semiconductor, Inc. 20 ** Copyright 2016 - 2017 NXP 21 ** Redistribution and use in source and binary forms, with or without modification, 22 ** are permitted provided that the following conditions are met: 23 ** 24 ** o Redistributions of source code must retain the above copyright notice, this list 25 ** of conditions and the following disclaimer. 26 ** 27 ** o Redistributions in binary form must reproduce the above copyright notice, this 28 ** list of conditions and the following disclaimer in the documentation and/or 29 ** other materials provided with the distribution. 30 ** 31 ** o Neither the name of the copyright holder nor the names of its 32 ** contributors may be used to endorse or promote products derived from this 33 ** software without specific prior written permission. 34 ** 35 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 36 ** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 37 ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 38 ** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 39 ** ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 40 ** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 41 ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 42 ** ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 43 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 44 ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 ** 46 ** http: www.nxp.com 47 ** mail: support@nxp.com 48 ** 49 ** Revisions: 50 ** - rev. 1.0 (2013-11-22) 51 ** Initial version. 52 ** - rev. 2.0 (2014-11-26) 53 ** update of SystemInit() imlementation 54 ** Module access macro module_BASES replaced by module_BASE_PTRS. 55 ** Register accessor macros added to the memory map. 56 ** MCG - bit LOLS in MCG_S register renamed to LOLS0. 57 ** DAC0 registers removed. 58 ** 59 ** ################################################################### 60 */ 61 62 /*! 63 * @file MKW24D5 64 * @version 2.0 65 * @date 2014-11-26 66 * @brief Device specific configuration file for MKW24D5 (header file) 67 * 68 * Provides a system configuration function and a global variable that contains 69 * the system frequency. It configures the device and initializes the oscillator 70 * (PLL) that is part of the microcontroller device. 71 */ 72 73 #ifndef _SYSTEM_MKW24D5_H_ 74 #define _SYSTEM_MKW24D5_H_ /**< Symbol preventing repeated inclusion */ 75 76 #ifdef __cplusplus 77 extern "C" { 78 #endif 79 80 #include <stdint.h> 81 82 83 #ifndef DISABLE_WDOG 84 #define DISABLE_WDOG 1 85 #endif 86 87 /* Define clock source values */ 88 89 #define CPU_XTAL32k_CLK_HZ 32768U /* Value of the external 32k crystal or oscillator clock frequency of the RTC in Hz */ 90 #define CPU_INT_SLOW_CLK_HZ 32768U /* Value of the slow internal oscillator clock frequency in Hz */ 91 #define CPU_INT_FAST_CLK_HZ 4000000U /* Value of the fast internal oscillator clock frequency in Hz */ 92 93 /* RTC oscillator setting */ 94 /* RTC_CR: SC2P=0,SC4P=0,SC8P=0,SC16P=0,CLKO=1,OSCE=1,WPS=0,UM=0,SUP=0,WPE=0,SWR=0 */ 95 #define SYSTEM_RTC_CR_VALUE 0x0300U /* RTC_CR */ 96 97 /* Low power mode enable */ 98 /* SMC_PMPROT: AVLP=1,ALLS=1,AVLLS=1 */ 99 #define SYSTEM_SMC_PMPROT_VALUE 0x2AU /* SMC_PMPROT */ 100 101 #define DEFAULT_SYSTEM_CLOCK 20971520U /* Default System clock value */ 102 #define CPU_XTAL_CLK_HZ 4000000U /* Value of the clock provided by the wireless modem by default */ 103 104 105 106 /** 107 * @brief Configure the external clock source 108 * 109 * The wireless modem present in the system can supply clock which can be used 110 * as a clock source for the whole system. This function is defined as weak. 111 * 112 */ 113 extern uint8_t ExtClk_Setup_HookUp(uint32_t clk_out_value); 114 /** 115 * @brief System clock frequency (core clock) 116 * 117 * The system clock frequency supplied to the SysTick timer and the processor 118 * core clock. This variable can be used by the user application to setup the 119 * SysTick timer or configure other parameters. It may also be used by debugger to 120 * query the frequency of the debug timer or configure the trace clock speed 121 * SystemCoreClock is initialized with a correct predefined value. 122 */ 123 extern uint32_t SystemCoreClock; 124 125 /** 126 * @brief Setup the microcontroller system. 127 * 128 * Typically this function configures the oscillator (PLL) that is part of the 129 * microcontroller device. For systems with variable clock speed it also updates 130 * the variable SystemCoreClock. SystemInit is called from startup_device file. 131 */ 132 void SystemInit (void); 133 134 /** 135 * @brief Updates the SystemCoreClock variable. 136 * 137 * It must be called whenever the core clock is changed during program 138 * execution. SystemCoreClockUpdate() evaluates the clock register settings and calculates 139 * the current core clock. 140 */ 141 void SystemCoreClockUpdate (void); 142 143 #ifdef __cplusplus 144 } 145 #endif 146 147 #endif /* _SYSTEM_MKW24D5_H_ */ 148