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