<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > LPC1114_時(shí)鐘系統(tǒng)解析

          LPC1114_時(shí)鐘系統(tǒng)解析

          作者: 時(shí)間:2016-11-29 來源:網(wǎng)絡(luò) 收藏
          一般我們?cè)趍ain()的開始部分都需要進(jìn)行時(shí)鐘的初始化,根據(jù)需要可以選擇時(shí)鐘源、是否開啟PLL倍頻、以及PLL配置達(dá)到所需要的輸出時(shí)鐘,然后再選擇倍頻后的時(shí)鐘作為主時(shí)鐘源。

          如下圖:需要注意幾個(gè)時(shí)鐘的概念,

          本文引用地址:http://www.ex-cimer.com/article/201611/323526.htm



          #define CLOCK_SETUP           1#define MAIN_PLL_SETUP        1#define MAIN_CLKSRCSEL_Val    0x00000001#define MAIN_PLL_M_Val        0x00000003#define MAIN_PLL_P_Val        0x00000001#define SYS_AHB_DIV_Val       1   /* 1 through 255, typical is 1 or 2 or 4 */#define XTAL        (12000000UL)        /* Oscillator frequency               */#define OSC_CLK     (      XTAL)        /* Main oscillator frequency          */#define IRC_OSC     (12000000UL)        /* Internal RC oscillator frequency   */#define WDT_OSC     (  250000UL)        /* WDT oscillator frequency           */uint32_t ClockSource = IRC_OSC;uint32_t SystemFrequency = IRC_OSC; /*!< System Clock Frequency (Core Clock)  */uint32_t SystemAHBFrequency = IRC_OSC;void Main_PLL_Setup ( void ){uint32_t regVal;ClockSource = OSC_CLK;LPC_SYSCON->SYSPLLCLKSEL = MAIN_CLKSRCSEL_Val;   /* Select system OSC--系統(tǒng)振蕩器 */LPC_SYSCON->SYSPLLCLKUEN = 0x01;                 /* Update clock source */LPC_SYSCON->SYSPLLCLKUEN = 0x00;                 /* toggle Update register once */LPC_SYSCON->SYSPLLCLKUEN = 0x01;while ( !(LPC_SYSCON->SYSPLLCLKUEN & 0x01) );    /* Wait until updated */regVal = LPC_SYSCON->SYSPLLCTRL;regVal &= ~0x1FF;LPC_SYSCON->SYSPLLCTRL = (regVal | (MAIN_PLL_P_Val<<5) | MAIN_PLL_M_Val);/* P=1, M=4 FCLKOUT=12*4=48Mhz *//* Enable main system PLL, main system PLL bit 7 in PDRUNCFG. */LPC_SYSCON->PDRUNCFG &= ~(0x1<<7);              /* PDRUNCFG第七位寫0,即系統(tǒng)PLL上電 */while ( !(LPC_SYSCON->SYSPLLSTAT & 0x01) );     /* Wait until its locked 確定PLL鎖定以后向下執(zhí)行 */LPC_SYSCON->MAINCLKSEL = 0x03;                /* Select PLL clock output--選擇PLL輸出作為主時(shí)鐘 */LPC_SYSCON->MAINCLKUEN = 0x01;                /* Update MCLK clock source --允許更新主時(shí)鐘*/LPC_SYSCON->MAINCLKUEN = 0x00;                /* Toggle update register once */LPC_SYSCON->MAINCLKUEN = 0x01;while ( !(LPC_SYSCON->MAINCLKUEN & 0x01) );     /* Wait until updated 確定主時(shí)鐘鎖定以后向下執(zhí)行 */LPC_SYSCON->SYSAHBCLKDIV = SYS_AHB_DIV_Val;     /* SYS AHB clock, typical is 1 or 2 or 4 --SYSAHBCLKDIV的值為1,即不分頻 使AHB時(shí)鐘設(shè)置為48Mhz */#if MAIN_PLL_SETUPSystemFrequency = ClockSource * (MAIN_PLL_M_Val+1);#elseSystemFrequency = ClockSource;#endifSystemAHBFrequency = (uint32_t)(SystemFrequency/SYS_AHB_DIV_Val);return;}/*** Initialize the system** @param  none* @return none** @brief  Setup the microcontroller system.*         Initialize the System and update the SystemFrequency variable.*/void SystemInit (void){uint32_t i;#ifdef __DEBUG_RAM   LPC_SYSCON->SYSMEMREMAP = 0x1;  /* remap to internal RAM */#else#ifdef __DEBUG_FLASH   LPC_SYSCON->SYSMEMREMAP = 0x2;  /* remap to internal flash */#endif#endif#if (CLOCK_SETUP)                       /* Clock Setup *//* bit 0 default is crystal bypass,bit1 0=0~20Mhz crystal input, 1=15~50Mhz crystal input. */LPC_SYSCON->SYSOSCCTRL = 0x00;/* main system OSC run is cleared, bit 5 in PDRUNCFG register */LPC_SYSCON->PDRUNCFG &= ~(0x1<<5);    /* PDRUNCFG的第五位寫0,即系統(tǒng)系統(tǒng)振蕩器上電 *//* Wait 200us for OSC to be stablized, no statusindication, dummy wait. */for ( i = 0; i < 0x100; i++ );#if (MAIN_PLL_SETUP)Main_PLL_Setup(); #endif#endif /* endif CLOCK_SETUP *//* System clock to the IOCON needs to be enabled ormost of the I/O related peripherals wont work. */LPC_SYSCON->SYSAHBCLKCTRL |= (1<<16);                  //使能IO模塊的時(shí)鐘return;}


          關(guān)鍵詞: LPC1114時(shí)鐘系

          評(píng)論


          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();