要得到100KPS/S的拨特率
stm32f10x_can.h: /* CAN synchronisation jump width */ #define CAN_SJW_1tq ((u8)0x00) /* 1 time quantum */ #define CAN_SJW_2tq ((u8)0x01) /* 2 time quantum */ #define CAN_SJW_3tq ((u8)0x02) /* 3 time quantum */ #define CAN_SJW_4tq ((u8)0x03) /* 4 time quantum */ #define IS_CAN_SJW(SJW) (((SJW) == CAN_SJW_1tq) || ((SJW) == CAN_SJW_2tq)|| ((SJW) == CAN_SJW_3tq) || ((SJW) == CAN_SJW_4tq)) /* time quantum in bit segment 1 */ #define CAN_BS1_1tq ((u8)0x00) /* 1 time quantum */ #define CAN_BS1_2tq ((u8)0x01) /* 2 time quantum */ #define CAN_BS1_3tq ((u8)0x02) /* 3 time quantum */ #define CAN_BS1_4tq ((u8)0x03) /* 4 time quantum */ #define CAN_BS1_5tq ((u8)0x04) /* 5 time quantum */ #define CAN_BS1_6tq ((u8)0x05) /* 6 time quantum */ #define CAN_BS1_7tq ((u8)0x06) /* 7 time quantum */ #define CAN_BS1_8tq ((u8)0x07) /* 8 time quantum */ #define CAN_BS1_9tq ((u8)0x08) /* 9 time quantum */ #define CAN_BS1_10tq ((u8)0x09) /* 10 time quantum */ #define CAN_BS1_11tq ((u8)0x0A) /* 11 time quantum */ #define CAN_BS1_12tq ((u8)0x0B) /* 12 time quantum */ #define CAN_BS1_13tq ((u8)0x0C) /* 13 time quantum */ #define CAN_BS1_14tq ((u8)0x0D) /* 14 time quantum */ #define CAN_BS1_15tq ((u8)0x0E) /* 15 time quantum */ #define CAN_BS1_16tq ((u8)0x0F) /* 16 time quantum */ #define IS_CAN_BS1(BS1) ((BS1) <= CAN_BS1_16tq) /* time quantum in bit segment 2 */ #define CAN_BS2_1tq ((u8)0x00) /* 1 time quantum */ #define CAN_BS2_2tq ((u8)0x01) /* 2 time quantum */ #define CAN_BS2_3tq ((u8)0x02) /* 3 time quantum */ #define CAN_BS2_4tq ((u8)0x03) /* 4 time quantum */ #define CAN_BS2_5tq ((u8)0x04) /* 5 time quantum */ #define CAN_BS2_6tq ((u8)0x05) /* 6 time quantum */ #define CAN_BS2_7tq ((u8)0x06) /* 7 time quantum */ #define CAN_BS2_8tq ((u8)0x07) /* 8 time quantum */ stm32f10x_can.c : /* Set the bit timing register */ CAN->BTR = (u32)((u32)CAN_InitStruct->CAN_Mode << 30) | ((u32)CAN_InitStruct->CAN_SJW << 24) | ((u32)CAN_InitStruct->CAN_BS1 << 16) | ((u32)CAN_InitStruct->CAN_BS2 << 20) | ((u32)CAN_InitStruct->CAN_Prescaler - 1); CAN_InitStructure.CAN_BS1=CAN_BS1_8tq; CAN_InitStructure.CAN_BS2=CAN_BS2_7tq; CAN_InitStructure.CAN_Prescaler=5; 上面参数设置CAN寄存器,要得到100KPS/S的拨特率,CAN时钟应该是18MHZ吧? 由此推断, CAN时钟应该是 8 MHz ( 使用 HSE 8MHz, PLL 不使用 ? ) 8M / 5 / ( 1+ 8 + 7 ) = 100 Khttps://bbs.eeworld.com.cn/club/bbs/list.asp?boardid=49&t=3079355&tp=%u5F97%u5230500Kb/s%u7684%u6CE2%u7279%u7387