RCC_APB1PeriphClockCmd(RCC_APB1Periph_CAN, ENABLE);
CAN_DeInit(); CAN_StructInit(&CAN_InitStructure); // CAN cell init CAN_InitStructure.CAN_TTCM=DISABLE; CAN_InitStructure.CAN_ABOM=DISABLE; CAN_InitStructure.CAN_AWUM=DISABLE; CAN_InitStructure.CAN_NART=DISABLE; CAN_InitStructure.CAN_RFLM=DISABLE; CAN_InitStructure.CAN_TXFP=DISABLE; CAN_InitStructure.CAN_Mode=CAN_Mode_Normal; #if(1) CAN_InitStructure.CAN_SJW=CAN_SJW_1tq; CAN_InitStructure.CAN_BS1=CAN_BS1_8tq; CAN_InitStructure.CAN_BS2=CAN_BS2_7tq; CAN_InitStructure.CAN_Prescaler=9; //此种设置CAN通讯不正常 #else CAN_InitStructure.CAN_SJW=CAN_SJW_1tq; CAN_InitStructure.CAN_BS1=CAN_BS1_6tq; CAN_InitStructure.CAN_BS2=CAN_BS2_5tq; CAN_InitStructure.CAN_Prescaler=12; //此种设置CAN通讯正常 #endif CAN_Init(&CAN_InitStructure); 时钟主频72MHZ,CAN通讯波特率采用250K,上面两种设置应该都是250K的波特率,为什么第2种设置能够正常,而第一种设置通讯不正常? |