#include
void SystemInit (void)
{
LPC_SC->SCS = 0x00000021; //主振蕩器使能
if (0x00000021 & (1 << 5))
{
while ((LPC_SC->SCS & (1<<6)) == 0);//等待主振蕩器穩(wěn)定
}
LPC_SC->CLKSRCSEL = 0x00000001; //時鐘源選擇--選擇主振蕩器作為系統(tǒng)時鐘與PLL0時鐘源
LPC_SC->PLL0CFG = 0x00000009; // 倍頻與分頻-M=10 P=1 pll_out_clk = 12M*10 = 120M F_cco = 240M
LPC_SC->PLL0CON = 0x01; //使能PLL0
LPC_SC->PLL0FEED = 0xAA; //饋送寄存器
LPC_SC->PLL0FEED = 0x55; //饋送寄存器
while (!(LPC_SC->PLL0STAT & (1<<10)));//等待PLL0鎖存
LPC_SC->PLL1CFG = 0x00000023;
LPC_SC->PLL1CON = 0x01;
LPC_SC->PLL1FEED = 0xAA;
LPC_SC->PLL1FEED = 0x55;
while (!(LPC_SC->PLL1STAT & (1<<10)));
LPC_SC->CCLKSEL = (0x00000001|(1<<8)); //CPU時鐘選擇寄存器--PLL作為CPU時鐘輸入且不分頻
LPC_SC->USBCLKSEL = (0x00000001|(0x02<<8)); //USB時鐘選擇寄存器--PLL作為USB時鐘輸入
LPC_SC->EMCCLKSEL = 0x00000001; //EMC時鐘選擇寄存器--EMC所有CPU一半的時鐘頻率
LPC_SC->PCLKSEL = 0x00000002; //外設(shè)時鐘選擇寄存器--輸入時鐘2分頻為外設(shè)APB時鐘
LPC_SC->PCONP = 0x042887DE; //外設(shè)功率控制寄存器
LPC_SC->CLKOUTCFG = 0x00000100; //時鐘輸出配置寄存器--CPU時鐘作為輸出--不分頻--使能CLKOUT
LPC_SC->FLASHCFG = 0x00005000|0x03A; //存儲器加速模塊配置寄存器---FLASH訪問使用6個CPU時鐘
SCB->VTOR = 0x00000000 & 0x3FFFFF80; //向量表偏移量寄存器--SRAM
}