1 /* 2 ** ################################################################### 3 ** Processors: MKW21Z256VHT4 4 ** MKW21Z512VHT4 5 ** 6 ** Compilers: Keil ARM C/C++ Compiler 7 ** GNU C Compiler 8 ** IAR ANSI C/C++ Compiler for ARM 9 ** MCUXpresso Compiler 10 ** 11 ** Reference manual: MKW41Z512RM Rev. 0.1, 04/2016 12 ** Version: rev. 1.0, 2015-09-23 13 ** Build: b170112 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 (c) 2016 Freescale Semiconductor, Inc. 21 ** Copyright 2016 - 2017 NXP 22 ** Redistribution and use in source and binary forms, with or without modification, 23 ** are permitted provided that the following conditions are met: 24 ** 25 ** o Redistributions of source code must retain the above copyright notice, this list 26 ** of conditions and the following disclaimer. 27 ** 28 ** o Redistributions in binary form must reproduce the above copyright notice, this 29 ** list of conditions and the following disclaimer in the documentation and/or 30 ** other materials provided with the distribution. 31 ** 32 ** o Neither the name of the copyright holder nor the names of its 33 ** contributors may be used to endorse or promote products derived from this 34 ** software without specific prior written permission. 35 ** 36 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 37 ** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 38 ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 39 ** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 40 ** ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 41 ** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 42 ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 43 ** ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 44 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 45 ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 46 ** 47 ** http: www.nxp.com 48 ** mail: support@nxp.com 49 ** 50 ** Revisions: 51 ** - rev. 1.0 (2015-09-23) 52 ** Initial version. 53 ** 54 ** ################################################################### 55 */ 56 57 /*! 58 * @file MKW21Z4 59 * @version 1.0 60 * @date 2015-09-23 61 * @brief Device specific configuration file for MKW21Z4 (header file) 62 * 63 * Provides a system configuration function and a global variable that contains 64 * the system frequency. It configures the device and initializes the oscillator 65 * (PLL) that is part of the microcontroller device. 66 */ 67 68 #ifndef _SYSTEM_MKW21Z4_H_ 69 #define _SYSTEM_MKW21Z4_H_ /**< Symbol preventing repeated inclusion */ 70 71 #ifdef __cplusplus 72 extern "C" { 73 #endif 74 75 #include <stdint.h> 76 77 78 #ifndef DISABLE_WDOG 79 #define DISABLE_WDOG 1 80 #endif 81 82 /* Define clock source values */ 83 84 #define CPU_XTAL_CLK_HZ 32000000u /* Value of the external crystal or oscillator clock frequency in Hz */ 85 #define CPU_XTAL32k_CLK_HZ 32768u /* Value of the external 32k crystal or oscillator clock frequency in Hz */ 86 #define CPU_INT_SLOW_CLK_HZ 32768u /* Value of the slow internal oscillator clock frequency in Hz */ 87 #define CPU_INT_FAST_CLK_HZ 4000000u /* Value of the fast internal oscillator clock frequency in Hz */ 88 89 /* RF oscillator setting */ 90 #define SYSTEM_RSIM_CONTROL_VALUE 0xC00100U /* Enable RF oscillator in Run/Wait mode */ 91 92 /* Low power mode enable */ 93 94 /* SMC_PMPROT: ?=0,?=0,AVLP=1,?=0,?=0,?=0,AVLLS=1,?=0 */ 95 #define SYSTEM_SMC_PMPROT_VALUE (SMC_PMPROT_AVLP_MASK | SMC_PMPROT_ALLS_MASK | SMC_PMPROT_AVLLS_MASK) /* Mask of allowed low power modes used to initialize power modes protection register */ 96 97 #define DEFAULT_SYSTEM_CLOCK 20971520U /* Default System clock value */ 98 99 100 /** 101 * @brief System clock frequency (core clock) 102 * 103 * The system clock frequency supplied to the SysTick timer and the processor 104 * core clock. This variable can be used by the user application to setup the 105 * SysTick timer or configure other parameters. It may also be used by debugger to 106 * query the frequency of the debug timer or configure the trace clock speed 107 * SystemCoreClock is initialized with a correct predefined value. 108 */ 109 extern uint32_t SystemCoreClock; 110 111 /** 112 * @brief Setup the microcontroller system. 113 * 114 * Typically this function configures the oscillator (PLL) that is part of the 115 * microcontroller device. For systems with variable clock speed it also updates 116 * the variable SystemCoreClock. SystemInit is called from startup_device file. 117 */ 118 void SystemInit (void); 119 120 /** 121 * @brief Updates the SystemCoreClock variable. 122 * 123 * It must be called whenever the core clock is changed during program 124 * execution. SystemCoreClockUpdate() evaluates the clock register settings and calculates 125 * the current core clock. 126 */ 127 void SystemCoreClockUpdate (void); 128 129 #ifdef __cplusplus 130 } 131 #endif 132 133 #endif /* _SYSTEM_MKW21Z4_H_ */ 134