void SystemInit (void)
{
#if (CLOCK_SETUP) /* Clock Setup */
LPC_SC->SCS = SCS_Val; /*主振荡器使能 */
if (SCS_Val & (1 << 5)) /* If Main Oscillator is enabled */
{
while ((LPC_SC->SCS & (1<<6)) == 0);/* Wait for Oscillator to be ready */
}
LPC_SC->CLKSRCSEL = CLKSRCSEL_Val; /* Select Clock Source for sysclk/PLL0 选择主振荡器作为sysclk/PLL0时钟源*/
#if (PLL0_SETUP)
LPC_SC->PLL0CFG = PLL0CFG_Val; /* PLL0 10倍频*/
LPC_SC->PLL0CON = 0x01; /* PLL0 Enable */
LPC_SC->PLL0FEED = 0xAA;
LPC_SC->PLL0FEED = 0x55;
while (!(LPC_SC->PLL0STAT & (1<<10)));/* Wait for PLOCK0 */
#endif
#if (PLL1_SETUP)
LPC_SC->PLL1CFG = PLL1CFG_Val; /* PLL0 24倍频*/
LPC_SC->PLL1CON = 0x01; /* PLL1 Enable */
LPC_SC->PLL1FEED = 0xAA;
LPC_SC->PLL1FEED = 0x55;
while (!(LPC_SC->PLL1STAT & (1<<10)));/* Wait for PLOCK1 */
#endif
LPC_SC->CCLKSEL = CCLKSEL_Val; /* 主PLL的输出作为CPU时钟分频器的输入,输入时钟1分频来产生CPU时钟 */
LPC_SC->USBCLKSEL = USBCLKSEL_Val; /* Alt PLL的输出作为USB时钟分频器的输入 */
LPC_SC->EMCCLKSEL = EMCCLKSEL_Val; /* EMC使用的时钟速率是CPU的一半 */
LPC_SC->PCLKSEL = PCLKSEL_Val; /* 输入时钟120M经过2分频产生APB时钟60M */
LPC_SC->PCONP = PCONP_Val; /* Power Control for Peripherals */
LPC_SC->CLKOUTCFG = CLKOUTCFG_Val; /* Clock Output 使能 */
#endif
#if (FLASH_SETUP == 1) /* Flash Accelerator Setup */
LPC_SC->FLASHCFG = FLASHCFG_Val|0x03A; /*FLASH使用6个CPU时钟,20M*/
#endif
#ifdef __RAM_MODE__
SCB->VTOR = 0x10000000 & 0x3FFFFF80;
#else
SCB->VTOR = 0x00000000 & 0x3FFFFF80;
#endif
}
上一篇:LPC1768菜鸟学习之ADC
下一篇:关于LPC1768的存储地址、运行地址、向量地址
推荐阅读最新更新时间:2024-03-16 16:18