C:/nxpdrv/LPC1700CMSIS/Core/CM3/DeviceSupport/NXP/LPC17xx/system_LPC17xx.c
Go to the documentation of this file.00001 /**************************************************************************/ 00026 #include <stdint.h> 00027 #include "LPC17xx.h" 00028 00029 /* 00030 //-------- <<< Use Configuration Wizard in Context Menu >>> ------------------ 00031 */ 00032 00033 /*--------------------- Clock Configuration ---------------------------------- 00034 // 00035 // <e> Clock Configuration 00036 // <h> System Controls and Status Register (SCS) 00037 // <o1.4> OSCRANGE: Main Oscillator Range Select 00038 // <0=> 1 MHz to 20 MHz 00039 // <1=> 15 MHz to 24 MHz 00040 // <e1.5> OSCEN: Main Oscillator Enable 00041 // </e> 00042 // </h> 00043 // 00044 // <h> Clock Source Select Register (CLKSRCSEL) 00045 // <o2.0..1> CLKSRC: PLL Clock Source Selection 00046 // <0=> Internal RC oscillator 00047 // <1=> Main oscillator 00048 // <2=> RTC oscillator 00049 // </h> 00050 // 00051 // <e3> PLL0 Configuration (Main PLL) 00052 // <h> PLL0 Configuration Register (PLL0CFG) 00053 // <i> F_cco0 = (2 * M * F_in) / N 00054 // <i> F_in must be in the range of 32 kHz to 50 MHz 00055 // <i> F_cco0 must be in the range of 275 MHz to 550 MHz 00056 // <o4.0..14> MSEL: PLL Multiplier Selection 00057 // <6-32768><#-1> 00058 // <i> M Value 00059 // <o4.16..23> NSEL: PLL Divider Selection 00060 // <1-256><#-1> 00061 // <i> N Value 00062 // </h> 00063 // </e> 00064 // 00065 // <e5> PLL1 Configuration (USB PLL) 00066 // <h> PLL1 Configuration Register (PLL1CFG) 00067 // <i> F_usb = M * F_osc or F_usb = F_cco1 / (2 * P) 00068 // <i> F_cco1 = F_osc * M * 2 * P 00069 // <i> F_cco1 must be in the range of 156 MHz to 320 MHz 00070 // <o6.0..4> MSEL: PLL Multiplier Selection 00071 // <1-32><#-1> 00072 // <i> M Value (for USB maximum value is 4) 00073 // <o6.5..6> PSEL: PLL Divider Selection 00074 // <0=> 1 00075 // <1=> 2 00076 // <2=> 4 00077 // <3=> 8 00078 // <i> P Value 00079 // </h> 00080 // </e> 00081 // 00082 // <h> CPU Clock Configuration Register (CCLKCFG) 00083 // <o7.0..7> CCLKSEL: Divide Value for CPU Clock from PLL0 00084 // <3-256><#-1> 00085 // </h> 00086 // 00087 // <h> USB Clock Configuration Register (USBCLKCFG) 00088 // <o8.0..3> USBSEL: Divide Value for USB Clock from PLL0 00089 // <0-15> 00090 // <i> Divide is USBSEL + 1 00091 // </h> 00092 // 00093 // <h> Peripheral Clock Selection Register 0 (PCLKSEL0) 00094 // <o9.0..1> PCLK_WDT: Peripheral Clock Selection for WDT 00095 // <0=> Pclk = Cclk / 4 00096 // <1=> Pclk = Cclk 00097 // <2=> Pclk = Cclk / 2 00098 // <3=> Pclk = Hclk / 8 00099 // <o9.2..3> PCLK_TIMER0: Peripheral Clock Selection for TIMER0 00100 // <0=> Pclk = Cclk / 4 00101 // <1=> Pclk = Cclk 00102 // <2=> Pclk = Cclk / 2 00103 // <3=> Pclk = Hclk / 8 00104 // <o9.4..5> PCLK_TIMER1: Peripheral Clock Selection for TIMER1 00105 // <0=> Pclk = Cclk / 4 00106 // <1=> Pclk = Cclk 00107 // <2=> Pclk = Cclk / 2 00108 // <3=> Pclk = Hclk / 8 00109 // <o9.6..7> PCLK_UART0: Peripheral Clock Selection for UART0 00110 // <0=> Pclk = Cclk / 4 00111 // <1=> Pclk = Cclk 00112 // <2=> Pclk = Cclk / 2 00113 // <3=> Pclk = Hclk / 8 00114 // <o9.8..9> PCLK_UART1: Peripheral Clock Selection for UART1 00115 // <0=> Pclk = Cclk / 4 00116 // <1=> Pclk = Cclk 00117 // <2=> Pclk = Cclk / 2 00118 // <3=> Pclk = Hclk / 8 00119 // <o9.12..13> PCLK_PWM1: Peripheral Clock Selection for PWM1 00120 // <0=> Pclk = Cclk / 4 00121 // <1=> Pclk = Cclk 00122 // <2=> Pclk = Cclk / 2 00123 // <3=> Pclk = Hclk / 8 00124 // <o9.14..15> PCLK_I2C0: Peripheral Clock Selection for I2C0 00125 // <0=> Pclk = Cclk / 4 00126 // <1=> Pclk = Cclk 00127 // <2=> Pclk = Cclk / 2 00128 // <3=> Pclk = Hclk / 8 00129 // <o9.16..17> PCLK_SPI: Peripheral Clock Selection for SPI 00130 // <0=> Pclk = Cclk / 4 00131 // <1=> Pclk = Cclk 00132 // <2=> Pclk = Cclk / 2 00133 // <3=> Pclk = Hclk / 8 00134 // <o9.20..21> PCLK_SSP1: Peripheral Clock Selection for SSP1 00135 // <0=> Pclk = Cclk / 4 00136 // <1=> Pclk = Cclk 00137 // <2=> Pclk = Cclk / 2 00138 // <3=> Pclk = Hclk / 8 00139 // <o9.22..23> PCLK_DAC: Peripheral Clock Selection for DAC 00140 // <0=> Pclk = Cclk / 4 00141 // <1=> Pclk = Cclk 00142 // <2=> Pclk = Cclk / 2 00143 // <3=> Pclk = Hclk / 8 00144 // <o9.24..25> PCLK_ADC: Peripheral Clock Selection for ADC 00145 // <0=> Pclk = Cclk / 4 00146 // <1=> Pclk = Cclk 00147 // <2=> Pclk = Cclk / 2 00148 // <3=> Pclk = Hclk / 8 00149 // <o9.26..27> PCLK_CAN1: Peripheral Clock Selection for CAN1 00150 // <0=> Pclk = Cclk / 4 00151 // <1=> Pclk = Cclk 00152 // <2=> Pclk = Cclk / 2 00153 // <3=> Pclk = Hclk / 6 00154 // <o9.28..29> PCLK_CAN2: Peripheral Clock Selection for CAN2 00155 // <0=> Pclk = Cclk / 4 00156 // <1=> Pclk = Cclk 00157 // <2=> Pclk = Cclk / 2 00158 // <3=> Pclk = Hclk / 6 00159 // <o9.30..31> PCLK_ACF: Peripheral Clock Selection for ACF 00160 // <0=> Pclk = Cclk / 4 00161 // <1=> Pclk = Cclk 00162 // <2=> Pclk = Cclk / 2 00163 // <3=> Pclk = Hclk / 6 00164 // </h> 00165 // 00166 // <h> Peripheral Clock Selection Register 1 (PCLKSEL1) 00167 // <o10.0..1> PCLK_QEI: Peripheral Clock Selection for the Quadrature Encoder Interface 00168 // <0=> Pclk = Cclk / 4 00169 // <1=> Pclk = Cclk 00170 // <2=> Pclk = Cclk / 2 00171 // <3=> Pclk = Hclk / 8 00172 // <o10.2..3> PCLK_GPIO: Peripheral Clock Selection for GPIOs 00173 // <0=> Pclk = Cclk / 4 00174 // <1=> Pclk = Cclk 00175 // <2=> Pclk = Cclk / 2 00176 // <3=> Pclk = Hclk / 8 00177 // <o10.4..5> PCLK_PCB: Peripheral Clock Selection for the Pin Connect Block 00178 // <0=> Pclk = Cclk / 4 00179 // <1=> Pclk = Cclk 00180 // <2=> Pclk = Cclk / 2 00181 // <3=> Pclk = Hclk / 8 00182 // <o10.6..7> PCLK_I2C1: Peripheral Clock Selection for I2C1 00183 // <0=> Pclk = Cclk / 4 00184 // <1=> Pclk = Cclk 00185 // <2=> Pclk = Cclk / 2 00186 // <3=> Pclk = Hclk / 8 00187 // <o10.10..11> PCLK_SSP0: Peripheral Clock Selection for SSP0 00188 // <0=> Pclk = Cclk / 4 00189 // <1=> Pclk = Cclk 00190 // <2=> Pclk = Cclk / 2 00191 // <3=> Pclk = Hclk / 8 00192 // <o10.12..13> PCLK_TIMER2: Peripheral Clock Selection for TIMER2 00193 // <0=> Pclk = Cclk / 4 00194 // <1=> Pclk = Cclk 00195 // <2=> Pclk = Cclk / 2 00196 // <3=> Pclk = Hclk / 8 00197 // <o10.14..15> PCLK_TIMER3: Peripheral Clock Selection for TIMER3 00198 // <0=> Pclk = Cclk / 4 00199 // <1=> Pclk = Cclk 00200 // <2=> Pclk = Cclk / 2 00201 // <3=> Pclk = Hclk / 8 00202 // <o10.16..17> PCLK_UART2: Peripheral Clock Selection for UART2 00203 // <0=> Pclk = Cclk / 4 00204 // <1=> Pclk = Cclk 00205 // <2=> Pclk = Cclk / 2 00206 // <3=> Pclk = Hclk / 8 00207 // <o10.18..19> PCLK_UART3: Peripheral Clock Selection for UART3 00208 // <0=> Pclk = Cclk / 4 00209 // <1=> Pclk = Cclk 00210 // <2=> Pclk = Cclk / 2 00211 // <3=> Pclk = Hclk / 8 00212 // <o10.20..21> PCLK_I2C2: Peripheral Clock Selection for I2C2 00213 // <0=> Pclk = Cclk / 4 00214 // <1=> Pclk = Cclk 00215 // <2=> Pclk = Cclk / 2 00216 // <3=> Pclk = Hclk / 8 00217 // <o10.22..23> PCLK_I2S: Peripheral Clock Selection for I2S 00218 // <0=> Pclk = Cclk / 4 00219 // <1=> Pclk = Cclk 00220 // <2=> Pclk = Cclk / 2 00221 // <3=> Pclk = Hclk / 8 00222 // <o10.26..27> PCLK_RIT: Peripheral Clock Selection for the Repetitive Interrupt Timer 00223 // <0=> Pclk = Cclk / 4 00224 // <1=> Pclk = Cclk 00225 // <2=> Pclk = Cclk / 2 00226 // <3=> Pclk = Hclk / 8 00227 // <o10.28..29> PCLK_SYSCON: Peripheral Clock Selection for the System Control Block 00228 // <0=> Pclk = Cclk / 4 00229 // <1=> Pclk = Cclk 00230 // <2=> Pclk = Cclk / 2 00231 // <3=> Pclk = Hclk / 8 00232 // <o10.30..31> PCLK_MC: Peripheral Clock Selection for the Motor Control PWM 00233 // <0=> Pclk = Cclk / 4 00234 // <1=> Pclk = Cclk 00235 // <2=> Pclk = Cclk / 2 00236 // <3=> Pclk = Hclk / 8 00237 // </h> 00238 // 00239 // <h> Power Control for Peripherals Register (PCONP) 00240 // <o11.1> PCTIM0: Timer/Counter 0 power/clock enable 00241 // <o11.2> PCTIM1: Timer/Counter 1 power/clock enable 00242 // <o11.3> PCUART0: UART 0 power/clock enable 00243 // <o11.4> PCUART1: UART 1 power/clock enable 00244 // <o11.6> PCPWM1: PWM 1 power/clock enable 00245 // <o11.7> PCI2C0: I2C interface 0 power/clock enable 00246 // <o11.8> PCSPI: SPI interface power/clock enable 00247 // <o11.9> PCRTC: RTC power/clock enable 00248 // <o11.10> PCSSP1: SSP interface 1 power/clock enable 00249 // <o11.12> PCAD: A/D converter power/clock enable 00250 // <o11.13> PCCAN1: CAN controller 1 power/clock enable 00251 // <o11.14> PCCAN2: CAN controller 2 power/clock enable 00252 // <o11.15> PCGPIO: GPIOs power/clock enable 00253 // <o11.16> PCRIT: Repetitive interrupt timer power/clock enable 00254 // <o11.17> PCMC: Motor control PWM power/clock enable 00255 // <o11.18> PCQEI: Quadrature encoder interface power/clock enable 00256 // <o11.19> PCI2C1: I2C interface 1 power/clock enable 00257 // <o11.21> PCSSP0: SSP interface 0 power/clock enable 00258 // <o11.22> PCTIM2: Timer 2 power/clock enable 00259 // <o11.23> PCTIM3: Timer 3 power/clock enable 00260 // <o11.24> PCUART2: UART 2 power/clock enable 00261 // <o11.25> PCUART3: UART 3 power/clock enable 00262 // <o11.26> PCI2C2: I2C interface 2 power/clock enable 00263 // <o11.27> PCI2S: I2S interface power/clock enable 00264 // <o11.29> PCGPDMA: GP DMA function power/clock enable 00265 // <o11.30> PCENET: Ethernet block power/clock enable 00266 // <o11.31> PCUSB: USB interface power/clock enable 00267 // </h> 00268 // 00269 // <h> Clock Output Configuration Register (CLKOUTCFG) 00270 // <o12.0..3> CLKOUTSEL: Selects clock source for CLKOUT 00271 // <0=> CPU clock 00272 // <1=> Main oscillator 00273 // <2=> Internal RC oscillator 00274 // <3=> USB clock 00275 // <4=> RTC oscillator 00276 // <o12.4..7> CLKOUTDIV: Selects clock divider for CLKOUT 00277 // <1-16><#-1> 00278 // <o12.8> CLKOUT_EN: CLKOUT enable control 00279 // </h> 00280 // 00281 // </e> 00282 */ 00283 #define CLOCK_SETUP 1 00284 #define SCS_Val 0x00000020 00285 #define CLKSRCSEL_Val 0x00000001 00286 #define PLL0_SETUP 1 00287 #define PLL0CFG_Val 0x00050063 00288 #define PLL1_SETUP 1 00289 #define PLL1CFG_Val 0x00000023 00290 #define CCLKCFG_Val 0x00000003 00291 #define USBCLKCFG_Val 0x00000000 00292 #define PCLKSEL0_Val 0x00000000 00293 #define PCLKSEL1_Val 0x00000000 00294 #define PCONP_Val 0x042887DE 00295 #define CLKOUTCFG_Val 0x00000000 00296 00297 00298 /*--------------------- Flash Accelerator Configuration ---------------------- 00299 // 00300 // <e> Flash Accelerator Configuration 00301 // <o1.0..11> Reserved 00302 // <o1.12..15> FLASHTIM: Flash Access Time 00303 // <0=> 1 CPU clock (for CPU clock up to 20 MHz) 00304 // <1=> 2 CPU clocks (for CPU clock up to 40 MHz) 00305 // <2=> 3 CPU clocks (for CPU clock up to 60 MHz) 00306 // <3=> 4 CPU clocks (for CPU clock up to 80 MHz) 00307 // <4=> 5 CPU clocks (for CPU clock up to 100 MHz) 00308 // <5=> 6 CPU clocks (for any CPU clock) 00309 // </e> 00310 */ 00311 #define FLASH_SETUP 1 00312 #define FLASHCFG_Val 0x0000303A 00313 00314 /* 00315 //-------- <<< end of configuration section >>> ------------------------------ 00316 */ 00317 00318 /*---------------------------------------------------------------------------- 00319 Check the register settings 00320 *----------------------------------------------------------------------------*/ 00321 #define CHECK_RANGE(val, min, max) ((val < min) || (val > max)) 00322 #define CHECK_RSVD(val, mask) (val & mask) 00323 00324 /* Clock Configuration -------------------------------------------------------*/ 00325 #if (CHECK_RSVD((SCS_Val), ~0x00000030)) 00326 #error "SCS: Invalid values of reserved bits!" 00327 #endif 00328 00329 #if (CHECK_RANGE((CLKSRCSEL_Val), 0, 2)) 00330 #error "CLKSRCSEL: Value out of range!" 00331 #endif 00332 00333 #if (CHECK_RSVD((PLL0CFG_Val), ~0x00FF7FFF)) 00334 #error "PLL0CFG: Invalid values of reserved bits!" 00335 #endif 00336 00337 #if (CHECK_RSVD((PLL1CFG_Val), ~0x0000007F)) 00338 #error "PLL1CFG: Invalid values of reserved bits!" 00339 #endif 00340 00341 #if ((CCLKCFG_Val != 0) && (((CCLKCFG_Val - 1) % 2))) 00342 #error "CCLKCFG: CCLKSEL field does not contain only odd values or 0!" 00343 #endif 00344 00345 #if (CHECK_RSVD((USBCLKCFG_Val), ~0x0000000F)) 00346 #error "USBCLKCFG: Invalid values of reserved bits!" 00347 #endif 00348 00349 #if (CHECK_RSVD((PCLKSEL0_Val), 0x000C0C00)) 00350 #error "PCLKSEL0: Invalid values of reserved bits!" 00351 #endif 00352 00353 #if (CHECK_RSVD((PCLKSEL1_Val), 0x03000300)) 00354 #error "PCLKSEL1: Invalid values of reserved bits!" 00355 #endif 00356 00357 #if (CHECK_RSVD((PCONP_Val), 0x10100821)) 00358 #error "PCONP: Invalid values of reserved bits!" 00359 #endif 00360 00361 #if (CHECK_RSVD((CLKOUTCFG_Val), ~0x000001FF)) 00362 #error "CLKOUTCFG: Invalid values of reserved bits!" 00363 #endif 00364 00365 /* Flash Accelerator Configuration -------------------------------------------*/ 00366 #if (CHECK_RSVD((FLASHCFG_Val), ~0x0000F07F)) 00367 #error "FLASHCFG: Invalid values of reserved bits!" 00368 #endif 00369 00370 00371 /*---------------------------------------------------------------------------- 00372 DEFINES 00373 *----------------------------------------------------------------------------*/ 00374 00375 /*---------------------------------------------------------------------------- 00376 Define clocks 00377 *----------------------------------------------------------------------------*/ 00378 #define XTAL (12000000UL) /* Oscillator frequency */ 00379 #define OSC_CLK ( XTAL) /* Main oscillator frequency */ 00380 #define RTC_CLK ( 32000UL) /* RTC oscillator frequency */ 00381 #define IRC_OSC ( 4000000UL) /* Internal RC oscillator frequency */ 00382 00383 00384 /* F_cco0 = (2 * M * F_in) / N */ 00385 #define __M (((PLL0CFG_Val ) & 0x7FFF) + 1) 00386 #define __N (((PLL0CFG_Val >> 16) & 0x00FF) + 1) 00387 #define __FCCO(__F_IN) ((2 * __M * __F_IN) / __N) 00388 #define __CCLK_DIV (((CCLKCFG_Val ) & 0x00FF) + 1) 00389 00390 /* Determine core clock frequency according to settings */ 00391 #if (PLL0_SETUP) 00392 #if ((CLKSRCSEL_Val & 0x03) == 1) 00393 #define __CORE_CLK (__FCCO(OSC_CLK) / __CCLK_DIV) 00394 #elif ((CLKSRCSEL_Val & 0x03) == 2) 00395 #define __CORE_CLK (__FCCO(RTC_CLK) / __CCLK_DIV) 00396 #else 00397 #define __CORE_CLK (__FCCO(IRC_OSC) / __CCLK_DIV) 00398 #endif 00399 #else 00400 #if ((CLKSRCSEL_Val & 0x03) == 1) 00401 #define __CORE_CLK (OSC_CLK / __CCLK_DIV) 00402 #elif ((CLKSRCSEL_Val & 0x03) == 2) 00403 #define __CORE_CLK (RTC_CLK / __CCLK_DIV) 00404 #else 00405 #define __CORE_CLK (IRC_OSC / __CCLK_DIV) 00406 #endif 00407 #endif 00408 00409 00410 /*---------------------------------------------------------------------------- 00411 Clock Variable definitions 00412 *----------------------------------------------------------------------------*/ 00413 uint32_t SystemCoreClock = __CORE_CLK; 00416 /*---------------------------------------------------------------------------- 00417 Clock functions 00418 *----------------------------------------------------------------------------*/ 00419 void SystemCoreClockUpdate (void) /* Get Core Clock Frequency */ 00420 { 00421 /* Determine clock frequency according to clock register values */ 00422 if (((LPC_SC->PLL0STAT >> 24) & 3) == 3) { /* If PLL0 enabled and connected */ 00423 switch (LPC_SC->CLKSRCSEL & 0x03) { 00424 case 0: /* Int. RC oscillator => PLL0 */ 00425 case 3: /* Reserved, default to Int. RC */ 00426 SystemCoreClock = (IRC_OSC * 00427 ((2 * ((LPC_SC->PLL0STAT & 0x7FFF) + 1))) / 00428 (((LPC_SC->PLL0STAT >> 16) & 0xFF) + 1) / 00429 ((LPC_SC->CCLKCFG & 0xFF)+ 1)); 00430 break; 00431 case 1: /* Main oscillator => PLL0 */ 00432 SystemCoreClock = (OSC_CLK * 00433 ((2 * ((LPC_SC->PLL0STAT & 0x7FFF) + 1))) / 00434 (((LPC_SC->PLL0STAT >> 16) & 0xFF) + 1) / 00435 ((LPC_SC->CCLKCFG & 0xFF)+ 1)); 00436 break; 00437 case 2: /* RTC oscillator => PLL0 */ 00438 SystemCoreClock = (RTC_CLK * 00439 ((2 * ((LPC_SC->PLL0STAT & 0x7FFF) + 1))) / 00440 (((LPC_SC->PLL0STAT >> 16) & 0xFF) + 1) / 00441 ((LPC_SC->CCLKCFG & 0xFF)+ 1)); 00442 break; 00443 } 00444 } else { 00445 switch (LPC_SC->CLKSRCSEL & 0x03) { 00446 case 0: /* Int. RC oscillator => PLL0 */ 00447 case 3: /* Reserved, default to Int. RC */ 00448 SystemCoreClock = IRC_OSC / ((LPC_SC->CCLKCFG & 0xFF)+ 1); 00449 break; 00450 case 1: /* Main oscillator => PLL0 */ 00451 SystemCoreClock = OSC_CLK / ((LPC_SC->CCLKCFG & 0xFF)+ 1); 00452 break; 00453 case 2: /* RTC oscillator => PLL0 */ 00454 SystemCoreClock = RTC_CLK / ((LPC_SC->CCLKCFG & 0xFF)+ 1); 00455 break; 00456 } 00457 } 00458 00459 } 00460 /* Exported types --------------------------------------------------------------*/ 00461 /* Exported constants --------------------------------------------------------*/ 00462 //extern unsigned long _sidata; /* start address for the initialization values of the .data section. defined in linker script */ 00463 //extern unsigned long _sdata; /* start address for the .data section. defined in linker script */ 00464 //extern unsigned long _edata; /* end address for the .data section. defined in linker script */ 00465 // 00466 //extern unsigned long _sbss; /* start address for the .bss section. defined in linker script */ 00467 //extern unsigned long _ebss; /* end address for the .bss section. defined in linker script */ 00468 00469 //void _init(void) 00470 //{ 00471 // unsigned long *pulSrc, *pulDest; 00472 // 00473 // // 00474 // // Copy the data segment initializers from flash to SRAM in ROM mode 00475 // // 00476 //#if (__RAM_MODE__==0) 00477 // pulSrc = &_sidata; 00478 // for(pulDest = &_sdata; pulDest < &_edata; ) 00479 // { 00480 // *(pulDest++) = *(pulSrc++); 00481 // } 00482 //#endif 00483 // 00484 // 00485 // // 00486 // // Zero fill the bss segment. 00487 // // 00488 // for(pulDest = &_sbss; pulDest < &_ebss; ) 00489 // { 00490 // *(pulDest++) = 0; 00491 // } 00492 //} 00493 00503 void SystemInit (void) 00504 { 00505 00506 #if (CLOCK_SETUP) /* Clock Setup */ 00507 LPC_SC->SCS = SCS_Val; 00508 if (SCS_Val & (1 << 5)) { /* If Main Oscillator is enabled */ 00509 while ((LPC_SC->SCS & (1<<6)) == 0);/* Wait for Oscillator to be ready */ 00510 } 00511 00512 LPC_SC->CCLKCFG = CCLKCFG_Val; /* Setup Clock Divider */ 00513 LPC_SC->PCLKSEL0 = PCLKSEL0_Val; /* Peripheral Clock Selection */ 00514 LPC_SC->PCLKSEL1 = PCLKSEL1_Val; 00515 00516 #if (PLL0_SETUP) 00517 LPC_SC->CLKSRCSEL = CLKSRCSEL_Val; /* Select Clock Source for PLL0 */ 00518 00519 LPC_SC->PLL0CFG = PLL0CFG_Val; /* configure PLL0 */ 00520 LPC_SC->PLL0FEED = 0xAA; 00521 LPC_SC->PLL0FEED = 0x55; 00522 00523 LPC_SC->PLL0CON = 0x01; /* PLL0 Enable */ 00524 LPC_SC->PLL0FEED = 0xAA; 00525 LPC_SC->PLL0FEED = 0x55; 00526 while (!(LPC_SC->PLL0STAT & (1<<26)));/* Wait for PLOCK0 */ 00527 00528 LPC_SC->PLL0CON = 0x03; /* PLL0 Enable & Connect */ 00529 LPC_SC->PLL0FEED = 0xAA; 00530 LPC_SC->PLL0FEED = 0x55; 00531 while (!(LPC_SC->PLL0STAT & ((1<<25) | (1<<24))));/* Wait for PLLC0_STAT & PLLE0_STAT */ 00532 #endif 00533 00534 #if (PLL1_SETUP) 00535 LPC_SC->PLL1CFG = PLL1CFG_Val; 00536 LPC_SC->PLL1FEED = 0xAA; 00537 LPC_SC->PLL1FEED = 0x55; 00538 00539 LPC_SC->PLL1CON = 0x01; /* PLL1 Enable */ 00540 LPC_SC->PLL1FEED = 0xAA; 00541 LPC_SC->PLL1FEED = 0x55; 00542 while (!(LPC_SC->PLL1STAT & (1<<10)));/* Wait for PLOCK1 */ 00543 00544 LPC_SC->PLL1CON = 0x03; /* PLL1 Enable & Connect */ 00545 LPC_SC->PLL1FEED = 0xAA; 00546 LPC_SC->PLL1FEED = 0x55; 00547 while (!(LPC_SC->PLL1STAT & ((1<< 9) | (1<< 8))));/* Wait for PLLC1_STAT & PLLE1_STAT */ 00548 #else 00549 LPC_SC->USBCLKCFG = USBCLKCFG_Val; /* Setup USB Clock Divider */ 00550 #endif 00551 LPC_SC->PCONP = PCONP_Val; /* Power Control for Peripherals */ 00552 00553 LPC_SC->CLKOUTCFG = CLKOUTCFG_Val; /* Clock Output Configuration */ 00554 #endif 00555 00556 #if (FLASH_SETUP == 1) /* Flash Accelerator Setup */ 00557 LPC_SC->FLASHCFG = FLASHCFG_Val; 00558 #endif 00559 }
Generated on Mon Feb 8 10:01:36 2010 for LPC1700CMSIS Standard Peripheral Firmware Library by
