added prescaler for 16 bit pwm in LPC1347 target

Fork of mbed-dev by mbed official

Committer:
JojoS
Date:
Sat Sep 10 15:32:04 2016 +0000
Revision:
147:ba84b7dc41a7
Parent:
144:ef7eb2e8f9f7
added prescaler for 16 bit timers (solution as in LPC11xx), default prescaler 31 for max 28 ms period time

Who changed what in which revision?

UserRevisionLine numberNew contents of line
<> 144:ef7eb2e8f9f7 1 /*
<> 144:ef7eb2e8f9f7 2 ** ###################################################################
<> 144:ef7eb2e8f9f7 3 ** Processors: MKL43Z128VLH4
<> 144:ef7eb2e8f9f7 4 ** MKL43Z128VMP4
<> 144:ef7eb2e8f9f7 5 ** MKL43Z256VLH4
<> 144:ef7eb2e8f9f7 6 ** MKL43Z256VMP4
<> 144:ef7eb2e8f9f7 7 **
<> 144:ef7eb2e8f9f7 8 ** Compilers: Keil ARM C/C++ Compiler
<> 144:ef7eb2e8f9f7 9 ** Freescale C/C++ for Embedded ARM
<> 144:ef7eb2e8f9f7 10 ** GNU C Compiler
<> 144:ef7eb2e8f9f7 11 ** IAR ANSI C/C++ Compiler for ARM
<> 144:ef7eb2e8f9f7 12 **
<> 144:ef7eb2e8f9f7 13 ** Reference manual: KL43P64M48SF6RM, Rev.3, Aug 2014
<> 144:ef7eb2e8f9f7 14 ** Version: rev. 1.6, 2015-07-29
<> 144:ef7eb2e8f9f7 15 ** Build: b151217
<> 144:ef7eb2e8f9f7 16 **
<> 144:ef7eb2e8f9f7 17 ** Abstract:
<> 144:ef7eb2e8f9f7 18 ** Provides a system configuration function and a global variable that
<> 144:ef7eb2e8f9f7 19 ** contains the system frequency. It configures the device and initializes
<> 144:ef7eb2e8f9f7 20 ** the oscillator (PLL) that is part of the microcontroller device.
<> 144:ef7eb2e8f9f7 21 **
<> 144:ef7eb2e8f9f7 22 ** Copyright (c) 2015 Freescale Semiconductor, Inc.
<> 144:ef7eb2e8f9f7 23 ** All rights reserved.
<> 144:ef7eb2e8f9f7 24 **
<> 144:ef7eb2e8f9f7 25 ** Redistribution and use in source and binary forms, with or without modification,
<> 144:ef7eb2e8f9f7 26 ** are permitted provided that the following conditions are met:
<> 144:ef7eb2e8f9f7 27 **
<> 144:ef7eb2e8f9f7 28 ** o Redistributions of source code must retain the above copyright notice, this list
<> 144:ef7eb2e8f9f7 29 ** of conditions and the following disclaimer.
<> 144:ef7eb2e8f9f7 30 **
<> 144:ef7eb2e8f9f7 31 ** o Redistributions in binary form must reproduce the above copyright notice, this
<> 144:ef7eb2e8f9f7 32 ** list of conditions and the following disclaimer in the documentation and/or
<> 144:ef7eb2e8f9f7 33 ** other materials provided with the distribution.
<> 144:ef7eb2e8f9f7 34 **
<> 144:ef7eb2e8f9f7 35 ** o Neither the name of Freescale Semiconductor, Inc. nor the names of its
<> 144:ef7eb2e8f9f7 36 ** contributors may be used to endorse or promote products derived from this
<> 144:ef7eb2e8f9f7 37 ** software without specific prior written permission.
<> 144:ef7eb2e8f9f7 38 **
<> 144:ef7eb2e8f9f7 39 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
<> 144:ef7eb2e8f9f7 40 ** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
<> 144:ef7eb2e8f9f7 41 ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
<> 144:ef7eb2e8f9f7 42 ** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
<> 144:ef7eb2e8f9f7 43 ** ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
<> 144:ef7eb2e8f9f7 44 ** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
<> 144:ef7eb2e8f9f7 45 ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
<> 144:ef7eb2e8f9f7 46 ** ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
<> 144:ef7eb2e8f9f7 47 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
<> 144:ef7eb2e8f9f7 48 ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<> 144:ef7eb2e8f9f7 49 **
<> 144:ef7eb2e8f9f7 50 ** http: www.freescale.com
<> 144:ef7eb2e8f9f7 51 ** mail: support@freescale.com
<> 144:ef7eb2e8f9f7 52 **
<> 144:ef7eb2e8f9f7 53 ** Revisions:
<> 144:ef7eb2e8f9f7 54 ** - rev. 1.0 (2014-03-27)
<> 144:ef7eb2e8f9f7 55 ** Initial version.
<> 144:ef7eb2e8f9f7 56 ** - rev. 1.1 (2014-05-26)
<> 144:ef7eb2e8f9f7 57 ** I2S registers TCR2/RCR2 and others were changed.
<> 144:ef7eb2e8f9f7 58 ** FLEXIO register FLEXIO_VERID has now bitfields: FEATURE, MINOR, MAJOR.
<> 144:ef7eb2e8f9f7 59 ** Names of the bitfields of the FLEXIO_SHIFTBUF have been changed to the appropriate register name e.g.: FLEXIO_SHIFTBUFBBS_SHIFTBUFBBS.
<> 144:ef7eb2e8f9f7 60 ** Peripheral_BASES macros has been changed to Peripheral_BASE_PTRS, e.g.: ADC_BASES to ADC_BASE_PTRS.
<> 144:ef7eb2e8f9f7 61 ** Clock configuration for high range external oscillator has been added.
<> 144:ef7eb2e8f9f7 62 ** RFSYS module access has been added.
<> 144:ef7eb2e8f9f7 63 ** - rev. 1.2 (2014-07-10)
<> 144:ef7eb2e8f9f7 64 ** GPIO - Renamed modules PTA,PTB,PTC,PTD,PTE to GPIOA,GPIOB,GPIOC,GPIOD,GPIOE.
<> 144:ef7eb2e8f9f7 65 ** UART0 - UART0 module renamed to UART2.
<> 144:ef7eb2e8f9f7 66 ** I2S - removed MDR register.
<> 144:ef7eb2e8f9f7 67 ** - rev. 1.3 (2014-08-21)
<> 144:ef7eb2e8f9f7 68 ** UART2 - Removed ED register.
<> 144:ef7eb2e8f9f7 69 ** UART2 - Removed MODEM register.
<> 144:ef7eb2e8f9f7 70 ** UART2 - Removed IR register.
<> 144:ef7eb2e8f9f7 71 ** UART2 - Removed PFIFO register.
<> 144:ef7eb2e8f9f7 72 ** UART2 - Removed CFIFO register.
<> 144:ef7eb2e8f9f7 73 ** UART2 - Removed SFIFO register.
<> 144:ef7eb2e8f9f7 74 ** UART2 - Removed TWFIFO register.
<> 144:ef7eb2e8f9f7 75 ** UART2 - Removed TCFIFO register.
<> 144:ef7eb2e8f9f7 76 ** UART2 - Removed RWFIFO register.
<> 144:ef7eb2e8f9f7 77 ** UART2 - Removed RCFIFO register.
<> 144:ef7eb2e8f9f7 78 ** USB - Removed bitfield REG_EN in CLK_RECOVER_IRC_EN register.
<> 144:ef7eb2e8f9f7 79 ** SIM - Changed bitfield value MCGIRCLK to LIRC_CLK of bitfield CLKOUTSEL in SOPT2 register.
<> 144:ef7eb2e8f9f7 80 ** SIM - Removed bitfield DIEID in SDID register.
<> 144:ef7eb2e8f9f7 81 ** - rev. 1.4 (2014-09-01)
<> 144:ef7eb2e8f9f7 82 ** USB - USB0_CTL0 was renamed to USB0_OTGCTL register.
<> 144:ef7eb2e8f9f7 83 ** USB - USB0_CTL1 was renamed to USB0_CTL register.
<> 144:ef7eb2e8f9f7 84 ** - rev. 1.5 (2014-09-05)
<> 144:ef7eb2e8f9f7 85 ** USB - Renamed USBEN bitfield of USB0_CTL was renamed to USBENSOFEN.
<> 144:ef7eb2e8f9f7 86 ** - rev. 1.6 (2015-07-29)
<> 144:ef7eb2e8f9f7 87 ** Correction of backward compatibility.
<> 144:ef7eb2e8f9f7 88 **
<> 144:ef7eb2e8f9f7 89 ** ###################################################################
<> 144:ef7eb2e8f9f7 90 */
<> 144:ef7eb2e8f9f7 91
<> 144:ef7eb2e8f9f7 92 /*!
<> 144:ef7eb2e8f9f7 93 * @file MKL43Z4
<> 144:ef7eb2e8f9f7 94 * @version 1.6
<> 144:ef7eb2e8f9f7 95 * @date 2015-07-29
<> 144:ef7eb2e8f9f7 96 * @brief Device specific configuration file for MKL43Z4 (header file)
<> 144:ef7eb2e8f9f7 97 *
<> 144:ef7eb2e8f9f7 98 * Provides a system configuration function and a global variable that contains
<> 144:ef7eb2e8f9f7 99 * the system frequency. It configures the device and initializes the oscillator
<> 144:ef7eb2e8f9f7 100 * (PLL) that is part of the microcontroller device.
<> 144:ef7eb2e8f9f7 101 */
<> 144:ef7eb2e8f9f7 102
<> 144:ef7eb2e8f9f7 103 #ifndef _SYSTEM_MKL43Z4_H_
<> 144:ef7eb2e8f9f7 104 #define _SYSTEM_MKL43Z4_H_ /**< Symbol preventing repeated inclusion */
<> 144:ef7eb2e8f9f7 105
<> 144:ef7eb2e8f9f7 106 #ifdef __cplusplus
<> 144:ef7eb2e8f9f7 107 extern "C" {
<> 144:ef7eb2e8f9f7 108 #endif
<> 144:ef7eb2e8f9f7 109
<> 144:ef7eb2e8f9f7 110 #include <stdint.h>
<> 144:ef7eb2e8f9f7 111
<> 144:ef7eb2e8f9f7 112
<> 144:ef7eb2e8f9f7 113 #ifndef DISABLE_WDOG
<> 144:ef7eb2e8f9f7 114 #define DISABLE_WDOG 1
<> 144:ef7eb2e8f9f7 115 #endif
<> 144:ef7eb2e8f9f7 116
<> 144:ef7eb2e8f9f7 117 #define ACK_ISOLATION 1
<> 144:ef7eb2e8f9f7 118
<> 144:ef7eb2e8f9f7 119 /* Define clock source values */
<> 144:ef7eb2e8f9f7 120
<> 144:ef7eb2e8f9f7 121 #define CPU_XTAL_CLK_HZ 32768u /* Value of the external crystal or oscillator clock frequency in Hz */
<> 144:ef7eb2e8f9f7 122 #define CPU_INT_FAST_CLK_HZ 48000000u /* Value of the fast internal oscillator clock frequency in Hz */
<> 144:ef7eb2e8f9f7 123 #define CPU_INT_IRC_CLK_HZ 48000000u /* Value of the 48M internal oscillator clock frequency in Hz */
<> 144:ef7eb2e8f9f7 124
<> 144:ef7eb2e8f9f7 125 /* Low power mode enable */
<> 144:ef7eb2e8f9f7 126 /* SMC_PMPROT: AVLP=1,AVLLS=1 */
<> 144:ef7eb2e8f9f7 127 #define SYSTEM_SMC_PMPROT_VALUE 0x2Au /* SMC_PMPROT */
<> 144:ef7eb2e8f9f7 128
<> 144:ef7eb2e8f9f7 129 #define DEFAULT_SYSTEM_CLOCK 8000000u /* Default System clock value */
<> 144:ef7eb2e8f9f7 130 #define CPU_INT_SLOW_CLK_HZ 8000000u /* Value of the slow internal oscillator clock frequency in Hz */
<> 144:ef7eb2e8f9f7 131
<> 144:ef7eb2e8f9f7 132
<> 144:ef7eb2e8f9f7 133 /**
<> 144:ef7eb2e8f9f7 134 * @brief System clock frequency (core clock)
<> 144:ef7eb2e8f9f7 135 *
<> 144:ef7eb2e8f9f7 136 * The system clock frequency supplied to the SysTick timer and the processor
<> 144:ef7eb2e8f9f7 137 * core clock. This variable can be used by the user application to setup the
<> 144:ef7eb2e8f9f7 138 * SysTick timer or configure other parameters. It may also be used by debugger to
<> 144:ef7eb2e8f9f7 139 * query the frequency of the debug timer or configure the trace clock speed
<> 144:ef7eb2e8f9f7 140 * SystemCoreClock is initialized with a correct predefined value.
<> 144:ef7eb2e8f9f7 141 */
<> 144:ef7eb2e8f9f7 142 extern uint32_t SystemCoreClock;
<> 144:ef7eb2e8f9f7 143
<> 144:ef7eb2e8f9f7 144 /**
<> 144:ef7eb2e8f9f7 145 * @brief Setup the microcontroller system.
<> 144:ef7eb2e8f9f7 146 *
<> 144:ef7eb2e8f9f7 147 * Typically this function configures the oscillator (PLL) that is part of the
<> 144:ef7eb2e8f9f7 148 * microcontroller device. For systems with variable clock speed it also updates
<> 144:ef7eb2e8f9f7 149 * the variable SystemCoreClock. SystemInit is called from startup_device file.
<> 144:ef7eb2e8f9f7 150 */
<> 144:ef7eb2e8f9f7 151 void SystemInit (void);
<> 144:ef7eb2e8f9f7 152
<> 144:ef7eb2e8f9f7 153 /**
<> 144:ef7eb2e8f9f7 154 * @brief Updates the SystemCoreClock variable.
<> 144:ef7eb2e8f9f7 155 *
<> 144:ef7eb2e8f9f7 156 * It must be called whenever the core clock is changed during program
<> 144:ef7eb2e8f9f7 157 * execution. SystemCoreClockUpdate() evaluates the clock register settings and calculates
<> 144:ef7eb2e8f9f7 158 * the current core clock.
<> 144:ef7eb2e8f9f7 159 */
<> 144:ef7eb2e8f9f7 160 void SystemCoreClockUpdate (void);
<> 144:ef7eb2e8f9f7 161
<> 144:ef7eb2e8f9f7 162 #ifdef __cplusplus
<> 144:ef7eb2e8f9f7 163 }
<> 144:ef7eb2e8f9f7 164 #endif
<> 144:ef7eb2e8f9f7 165
<> 144:ef7eb2e8f9f7 166 #endif /* _SYSTEM_MKL43Z4_H_ */