看了一圈,这个片子没有人发个类似的,发个文章记录调试
1、调试了HC32F4A0 CANFD? ? ? ? ? ? ? ? ? ? ? ?
? ? ?调试环境用的HC32FA0 开发板?
? ? 用的是can1测试
?测试华大的教程,测试验证 仲裁端为 1M 数据端为8M? ? ? ? ? ? ? ? ? ? ? ? ?
?以下是华大的配置
2、具体的计算公式
不想计算的的小伙伴,可以参考下手册时钟对应波特率图,用户手册上1353页
3、配置这个要注意的一点是? ??CAN_FD_TDC_DISABLE? ?这个禁止。
? ? ?至于为什么,我也不懂,懂得朋友告诉一声
//500k canfd 配置 在时钟80M通讯
/* Initializes CAN. */
(void)CAN_StructInit(&stcCanInit); //500k 仲裁域的500k配置
stcCanInit.stcBitCfg.u32Prescaler = 4U;
stcCanInit.stcBitCfg.u32TimeSeg1 = 32U;
stcCanInit.stcBitCfg.u32TimeSeg2 = 8U;
stcCanInit.stcBitCfg.u32SJW = 8U;
stcCanInit.pstcFilter = astcFilter;
stcCanInit.u16FilterSelect = CAN_FILTER_SEL;
stcCanInit.u8WorkMode = CAN_WORK_MD_NORMAL;
/* CAN-FD configuration. */
(void)CAN_FD_StructInit(&stcCanFd); //500K 数据域的500k配置
stcCanFd.stcBitCfg.u32Prescaler = 8U;
stcCanFd.stcBitCfg.u32TimeSeg1 = 16U;
stcCanFd.stcBitCfg.u32TimeSeg2 = 4U;
stcCanFd.stcBitCfg.u32SJW = 4U;
stcCanFd.u8TDC = CAN_FD_TDC_DISABLE;
stcCanFd.u8SSPOffset = stcCanFd.stcBitCfg.u32TimeSeg1; /* Equal to SEG1 is suggested. */
stcCanInit.pstcCanFd = &stcCanFd;
以下的是测试数据
4、以下是调试完成? ? 1M? ?2M? ?4M? 的代码
1M
// 1m
/* Initializes CAN. */
(void)CAN_StructInit(&stcCanInit); //500k
stcCanInit.stcBitCfg.u32Prescaler = 4U;
stcCanInit.stcBitCfg.u32TimeSeg1 = 32U;
stcCanInit.stcBitCfg.u32TimeSeg2 = 8U;
stcCanInit.stcBitCfg.u32SJW = 8U;
stcCanInit.pstcFilter = astcFilter;
stcCanInit.u16FilterSelect = CAN_FILTER_SEL;
stcCanInit.u8WorkMode = CAN_WORK_MD_NORMAL;
/* CAN-FD configuration. */
(void)CAN_FD_StructInit(&stcCanFd); //1M
stcCanFd.stcBitCfg.u32Prescaler = 4U;
stcCanFd.stcBitCfg.u32TimeSeg1 = 16U;
stcCanFd.stcBitCfg.u32TimeSeg2 = 4U;
stcCanFd.stcBitCfg.u32SJW = 4U;
stcCanFd.u8TDC = CAN_FD_TDC_DISABLE;
stcCanFd.u8SSPOffset = stcCanFd.stcBitCfg.u32TimeSeg1; /* Equal to SEG1 is suggested. */
stcCanInit.pstcCanFd = &stcCanFd;
2M
/* Initializes CAN. */
(void)CAN_StructInit(&stcCanInit); //1M
stcCanInit.stcBitCfg.u32Prescaler = 1U;
stcCanInit.stcBitCfg.u32TimeSeg1 = 64U;
stcCanInit.stcBitCfg.u32TimeSeg2 = 16U;
stcCanInit.stcBitCfg.u32SJW = 16U;
stcCanInit.pstcFilter = astcFilter;
stcCanInit.u16FilterSelect = CAN_FILTER_SEL;
stcCanInit.u8WorkMode = CAN_WORK_MD_NORMAL;
/* CAN-FD configuration. */
(void)CAN_FD_StructInit(&stcCanFd); //2M
stcCanFd.stcBitCfg.u32Prescaler = 2U;
stcCanFd.stcBitCfg.u32TimeSeg1 = 16U;
stcCanFd.stcBitCfg.u32TimeSeg2 = 4U;
stcCanFd.stcBitCfg.u32SJW = 4U;
stcCanFd.u8TDC = CAN_FD_TDC_ENABLE;
stcCanFd.u8SSPOffset = stcCanFd.stcBitCfg.u32TimeSeg1; /* Equal to SEG1 is suggested. */
stcCanInit.pstcCanFd = &stcCanFd;
4M
/* Initializes CAN. */
(void)CAN_StructInit(&stcCanInit);
stcCanInit.stcBitCfg.u32Prescaler = 1U; //1M
stcCanInit.stcBitCfg.u32TimeSeg1 = 64U;
stcCanInit.stcBitCfg.u32TimeSeg2 = 16U;
stcCanInit.stcBitCfg.u32SJW = 16U;
stcCanInit.pstcFilter = astcFilter;
stcCanInit.u16FilterSelect = CAN_FILTER_SEL;
stcCanInit.u8WorkMode = CAN_WORK_MD_NORMAL;
/* CAN-FD configuration. */
(void)CAN_FD_StructInit(&stcCanFd); //4M
stcCanFd.stcBitCfg.u32Prescaler = 1U;
stcCanFd.stcBitCfg.u32TimeSeg1 = 16U;
stcCanFd.stcBitCfg.u32TimeSeg2 = 4U;
stcCanFd.stcBitCfg.u32SJW = 4U;
stcCanFd.u8TDC = CAN_FD_TDC_ENABLE;
stcCanFd.u8SSPOffset = stcCanFd.stcBitCfg.u32TimeSeg1; /* Equal to SEG1 is suggested. */
stcCanInit.pstcCanFd = &stcCanFd;
|