void RCC_Configuration(void)
{
ErrorStatus HSEStartUpStatus;
u8 len;
RCC_DeInit();
RCC_HSEConfig(RCC_HSE_ON);
HSEStartUpStatus=RCC_WaitForHSEStartUp();
if(HSEStartUpStatus==SUCCESS)
{
FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
FLASH_SetLatency(FLASH_Latency_2);
}
RCC_HCLKConfig(RCC_SYSCLK_Div1);
RCC_PCLK1Config(RCC_HCLK_Div4);
RCC_PLLConfig(RCC_PLLSource_PREDIV1,RCC_PLLMul_4);
RCC_PLLCmd(ENABLE);
while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY)==RESET)
{
}
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
while(RCC_GetSYSCLKSource()!=0X08)
{
}
RCC_APB1PeriphClockCmd(RCC_APB1Periph_CAN1, ENABLE);
}
CAN_InitStructure.CAN_SJW = CAN_SJW_2tq; /* 波特率相关设置 */
CAN_InitStructure.CAN_BS1 = CAN_BS1_16tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_8tq;
CAN_InitStructure.CAN_Prescaler = 2;
我的晶振是25M的,利用上面的参数得到CAN波特率为500kps,根据网上搜查资料,需要知道CAN系统时钟,哪位大虾告诉我根据上面的设置推算出CAN系统时钟怎么不对啊? |