如题,为什么RCC_PCLK1Config(RCC_HCLK_Div2)函数不起作用?
代码如下:static void Clock_Init(void)
{
ErrorStatus HSEStartUpStatus;
//Init RCC external facilities register
RCC_DeInit();
//Turn on the External High Speed oscillator (HSE).
RCC_HSEConfig(RCC_HSE_ON);
//Waits for HSE start-up.
HSEStartUpStatus = RCC_WaitForHSEStartUp();
//HSE is ready
if(HSEStartUpStatus == SUCCESS)
{
//Enables the Prefetch Buffer
//FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
//Sets the code latency value to FLASH Two Latency cycles
//FLASH_SetLatency(FLASH_Latency_2);
//Configures the AHB clock (HCLK).32MHz
RCC_HCLKConfig(RCC_SYSCLK_Div1);
//Configures the Low Speed APB clock (PCLK1).16MHz
RCC_PCLK1Config(RCC_HCLK_Div2);
//Configures the High Speed APB clock (PCLK2). 32MHz
RCC_PCLK2Config(RCC_HCLK_Div1);
RCC_PLLConfig(RCC_PLLSource_PREDIV1, RCC_PLLMul_4);
RCC_PLLCmd(ENABLE);
while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET);
//Enables the RCC_SYSCLKSource_HSE.
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
//Check HSE used as system clock or not
while(RCC_GetSYSCLKSource() != 0x08)
{
// TODO : doing some thing here to prevent problem
}
}
else
{
// TODO : What append if not ?
}
}
初始化完成以后,我使用TIM3,预将period time设置为1ms,参数如下:#define PRESCALER_TIMER3 ((uint16_t)15) /*FCK_CNT = 16MHz / (15 + 1) = 1us */
#define PERIOD_TIMER3 ((uint16_t)999) /*T3 = FCK_CNT * PSC = 1us * (999 + 1) = 1ms */
但用示波器查看Δt = 500us 小了一倍,而后我改为 PRESCALER_TIMER3 ((uint16_t)31) ,Δt = 1.00ms了,这样岂不是证明APB1分频得到32MHz频率吗? 可我设置的是16MHz , 求解。 |