程序加上这一句CAN_enableTestMode(CANA_BASE,CAN_TEST_EXL); 就可以实现发送 将那一句屏蔽后 就不能发送了
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
程序加上这一句CAN_enableTestMode(CANA_BASE,CAN_TEST_EXL); 就可以实现发送 将那一句屏蔽后 就不能发送了
for(;;)
{
//
// Check the error flag to see if errors occurred
//
//if(errorFlag)
//{
//asm(" ESTOP0");
//}
DEVICE_DELAY_US(250000);
//
// Verify that the number of transmitted messages equal the number of
// messages received before sending a new message
//
// if(txMsgCount == rxMsgCount)
// {
CAN_sendMessage(CANA_BASE, TX_MSG_OBJ_ID, MSG_DATA_LENGTH,
txMsgData);
// }
// else
// {
// errorFlag = 1;
// }
//
// Delay 1 second before continuing
//
DEVICE_DELAY_US(250000);
//
// Increment the value in the transmitted message data.
//
txMsgData[0] += 0x01;
txMsgData[1] += 0x01;
txMsgData[2] += 0x01;
txMsgData[3] += 0x01;
txMsgData[4] += 0x01;
txMsgData[5] += 0x01;
txMsgData[6] += 0x01;
txMsgData[7] += 0x01;
//
// Reset data if exceeds a byte
//
if(txMsgData[0] > 0xFF)
{
txMsgData[0] = 0;
}
if(txMsgData[1] > 0xFF)
{
txMsgData[1] = 0;
}
if(txMsgData[2] > 0xFF)
{
txMsgData[2] = 0;
}
if(txMsgData[3] > 0xFF)
{
txMsgData[3] = 0;
}
if(txMsgData[4] > 0xFF)
{
txMsgData[4] = 0;
}
if(txMsgData[5] > 0xFF)
{
txMsgData[5] = 0;
}
if(txMsgData[6] > 0xFF)
{
txMsgData[6] = 0;
}
if(txMsgData[7] > 0xFF)
{
txMsgData[7] = 0;
}
}
}主循环处的代码逻辑是这样的 这段代码如果是不需要使用外部回环而是使用CAN 总线进行通信的话是可以删除的。