如果我按下面的配置 /*setupclock function*/ void SetupClock(void) { RCC_DeInit (); /* RCC system reset(for debug purpose)*/ RCC_HSEConfig (RCC_HSE_ON); /* Enable HSE */
/* Wait till HSE is ready */ while (RCC_GetFlagStatus(RCC_FLAG_HSERDY) == RESET);
RCC_HCLKConfig (RCC_SYSCLK_Div1); /* HCLK = SYSCLK */ RCC_PCLK2Config (RCC_HCLK_Div1); /* PCLK2 = HCLK */ RCC_PCLK1Config (RCC_HCLK_Div2); /* PCLK1 = HCLK/2 */ RCC_ADCCLKConfig (RCC_PCLK2_Div4); /* ADCCLK = PCLK2/4 */
*(vu32 *)0x40022000 = 0x01; /* Flash 2 wait state */
/* PLLCLK = 8MHz * 9 = 72 MHz */ RCC_PLLConfig (RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);
RCC_PLLCmd (ENABLE); /* Enable PLL */
/* Wait till PLL is ready */ while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET);
/* Select PLL as system clock source */ RCC_SYSCLKConfig (RCC_SYSCLKSource_PLLCLK);
/* Wait till PLL is used as system clock source */ while (RCC_GetSYSCLKSource() != 0x08); /* Enable USART1 and GPIOA clock */ SysTick_SetReload(90000); SysTick_ITConfig(ENABLE); /* Enable SysTick interrupt */ } 这时的时钟节拍是1/9M,如果我按下面配置 void SetupClock(void) { // RCC_ClocksTypeDef RCC_ClockFreq; /* SYSCLK, HCLK, PCLK2 and PCLK1 configuration -----------------------------*/ /* RCC system reset(for debug purpose) */ RCC_DeInit (); /* RCC system reset(for debug purpose)*/ // RCC_HSICmd(ENABLE); /* Wait till HSE is ready */ RCC_HSEConfig(RCC_HSE_OFF); RCC_HSICmd(ENABLE);
RCC_HCLKConfig (RCC_SYSCLK_Div2); /* HCLK = SYSCLK */ RCC_PCLK2Config (RCC_HCLK_Div1); /* PCLK2 = HCLK */ RCC_PCLK1Config (RCC_HCLK_Div1); /* PCLK1 = HCLK/2 */ RCC_ADCCLKConfig (RCC_PCLK2_Div8); /* ADCCLK = PCLK2/4 */
*(vu32 *)0x40022000 = 0x01; /* Flash 2 wait state */
/* PLLCLK = 8MHz * 9 = 72 MHz */ RCC_PLLConfig (RCC_PLLSource_HSI_Div2, RCC_PLLMul_12);
RCC_PLLCmd (ENABLE); /* Enable PLL */
/* Wait till PLL is ready */ while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET);
/* Select PLL as system clock source */ RCC_SYSCLKConfig (RCC_SYSCLKSource_PLLCLK);
/* Wait till PLL is used as system clock source */ while (RCC_GetSYSCLKSource() != 0x08); /* Enable USART1 and GPIOA clock */
/* SysTick event each 10 ms with input clock equal to 9MHz (HCLK/8) */ //SysTick_SetReload(90000);
//RCC_MCOConfig(RCC_MCO_NoClock); RCC_LSEConfig(RCC_LSE_OFF); /* Disable APB1 Peripheral Clock */ //RCC->APB1ENR = 0x00000000; SysTick_SetReload(1200000/(LCDY*70)); SysTick_ITConfig(ENABLE); /* Enable SysTick interrupt */ } 这时的节拍是1/3M,这个时钟节拍跟什么有关呢? |