LPC1788--SYSTEM--启动文件记录
扫描二维码
随时随地手机看文章
#include
void SystemInit (void)
{
LPC_SC->SCS = 0x00000021; //主振荡器使能
if (0x00000021 & (1 << 5))
{
while ((LPC_SC->SCS & (1<<6)) == 0);//等待主振荡器稳定
}
LPC_SC->CLKSRCSEL = 0x00000001; //时钟源选择--选择主振荡器作为系统时钟与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; //外设时钟选择寄存器--输入时钟2分频为外设APB时钟
LPC_SC->PCONP = 0x042887DE; //外设功率控制寄存器
LPC_SC->CLKOUTCFG = 0x00000100; //时钟输出配置寄存器--CPU时钟作为输出--不分频--使能CLKOUT
LPC_SC->FLASHCFG = 0x00005000|0x03A; //存储器加速模块配置寄存器---FLASH访问使用6个CPU时钟
SCB->VTOR = 0x00000000 & 0x3FFFFF80; //向量表偏移量寄存器--SRAM
}