本帖最后由 followme001 于 2019-12-4 08:45 编辑
大家好,我的硬件是用的是NUC029LAN,外接12M晶振,用的是官网"NUC029xANBSP_CMSIS_v3.00.004",现在是套用里面文件夹SampleCode->StdDriver->GPIO_OutputInput工程里的代码,以下是它main.c里面的初始化代码,被卡在红色字体那一行,
void SYS_Init(void)
{
/*---------------------------------------------------------------------------------------------------------*/
/* Init System Clock */
/*---------------------------------------------------------------------------------------------------------*/
/* Enable Internal RC 22.1184MHz clock */
CLK_EnableXtalRC(CLK_PWRCON_OSC22M_EN_Msk);
/* Waiting for Internal RC clock ready */
CLK_WaitClockReady(CLK_CLKSTATUS_OSC22M_STB_Msk);
/* Switch HCLK clock source to Internal RC and HCLK source divide 1 */
CLK_SetHCLK(CLK_CLKSEL0_HCLK_S_HIRC, CLK_CLKDIV_HCLK(1));
/* Enable external XTAL 12MHz clock */
CLK_EnableXtalRC(CLK_PWRCON_XTL12M_EN_Msk);
/* Waiting for external XTAL clock ready */
CLK_WaitClockReady(CLK_CLKSTATUS_XTL12M_STB_Msk);
/* Set core clock as PLL_CLOCK from PLL */
CLK_SetCoreClock(PLL_CLOCK); //-----------------------------------------------------------#define PLL_CLOCK 50000000最上面有宏定义为50M
/* Enable UART module clock */
CLK_EnableModuleClock(UART0_MODULE);
/* Select UART module clock source */
CLK_SetModuleClock(UART0_MODULE, CLK_CLKSEL1_UART_S_PLL, CLK_CLKDIV_UART(1));
/*---------------------------------------------------------------------------------------------------------*/
/* Init I/O Multi-function */
/*---------------------------------------------------------------------------------------------------------*/
/* Set P3 multi-function pins for UART0 RXD and TXD */
SYS->P3_MFP &= ~(SYS_MFP_P30_Msk | SYS_MFP_P31_Msk);
SYS->P3_MFP |= (SYS_MFP_P30_RXD0 | SYS_MFP_P31_TXD0);
跳转到帮助文档有函数的定义:
uint32_t CLK_SetCoreClock | ( | uint32_t | u32Hclk | ) | |
Set HCLK frequency.
Parameters[in] | u32Hclk | is HCLK frequency | ReturnsHCLK frequency
然后又跳到CLK_EnablePLLu32Hclk = CLK_EnablePLL(CLK_PLLCON_PLL_SRC_HXT, u32Hclk);
uint32_t CLK_EnablePLL | ( | uint32_t | u32PllClkSrc, | | | uint32_t | u32PllFreq | | ) | | |
Set PLL frequency.
Parameters[in] | u32PllClkSrc | is PLL clock source. Including : | [in] | u32PllFreq | is PLL frequency | ReturnsPLL frequency
然后这是用户手册里关于PLL时钟设置的计算公式:
最后以下代码是计算什么NR NF NO的,以便代入
几个For循环看晕了,不知道最后算出来u32MinNR u32MinNF是多少?有高手懂吗?
}
|