卧听桃花雨 发表于 2019-6-27 08:44
后来又使用了中断来进行发送,在发送中断回调函数中发送下一帧报文。但是仍然存在丢包的情况。例如:我在发送中断中会发送id=0-9的10个报文,使用500K的波特率。理论发送间隔为300us,我在CAN卡上观测到的现象是ID=0-4的报文在不断循环的发送,间隔都是300us。 ...
你好,
可用这种方式实现连续发送:
frameType = CANFD_MCANFrameType_FD;while (1)[ j++; txMsgObjectParams.msgIdentifier =0xC5 + j; retVal = Can_Transmit_Schedule(txMsgObjHandle,txMsgObjectParams.msgIdentifier,&txData[0], 64);]int32_t Can_Transmit_Schedule(CANFD_MsgObjHandle txMsgObjHandle, uint32_t msg_id, uint8_t *txmsg, uint32_t len)[ uint32_t index = 0; int32_t retVal = 0; int32_t errCode = 0; if(frameType == CANFD_MCANFrameType_FD) [ while(len > 64U) [ Task_sleep(1); retVal = CANFD_transmitData (txMsgObjHandle, msg_id, CANFD_MCANFrameType_FD, 64U, &txmsg[index], &errCode); index = index + 64U; len = len - 64U; ] Task_sleep(1); retVal = CANFD_transmitData (txMsgObjHandle, msg_id, CANFD_MCANFrameType_FD, len, &txmsg[index], &errCode); ] else [ while(len > 8U) [ retVal = CANFD_transmitData (txMsgObjHandle, msg_id, CANFD_MCANFrameType_CLASSIC, 8U, &txmsg[index], &errCode); index = index + 8U; len = len - 8U; ] retVal = CANFD_transmitData (txMsgObjHandle, msg_id, CANFD_MCANFrameType_CLASSIC, len, &txmsg[index], &errCode); ] if (retVal < 0) [ System_printf("Debug: Error transmitting CAN data %x , Errcode %xn", retVal, errCode); ] return retVal;]
参考链接: