Hi J_D,
As you told i set breakpoint near CAN1_Transmit(CAN_PRIORITY_HIGH, &txCanMsg); and started debugging. while doing so the status of txMsgStatus is shown as CAN_TX_MESSAGE_REQUEST_FULL == 0X0003. so the message send failed. how to clear this issue? i attached the image of the debugging screen for reference. I made changes to the code which i attached below. And also the message buffer is always showing NULL value even though i loaded the message object with values. while debugging i attached CAN bus analyzer the bus analyzer shows error passive when the cursor comes to breakpoint near CAN1_Transmit(CAN_PRIORITY_HIGH, &txCanMsg);. Related images are attached.
#include "mcc_generated_files/system.h"
#include "mcc_generated_files/can1.h"
//#pragma config ICS = PGD2
//_FICD(ICS_PGD2);
int main(void)
{
uint8_t data[8] = {0,1,2,3,4,5,6,7};
uint8_t msgObjData[8] = {0,1,2,3,4,5,6,7};
CAN_MSG_OBJ rxCanMsg;
rxCanMsg.data = data;
CAN_MSG_OBJ txCanMsg;
//txCanMsg.data = msgObjData;
// initialize the device
SYSTEM_Initialize();
CAN1_TransmitEnable();
CAN1_ReceiveEnable();
CAN1_OperationModeSet(CAN_CONFIGURATION_MODE);
if(CAN_CONFIGURATION_MODE == CAN1_OperationModeGet())
{
if(CAN_OP_MODE_REQUEST_SUCCESS == CAN1_OperationModeSet(CAN_NORMAL_2_0_MODE))
{
while(1)
{
// if(CAN1_ReceivedMessageCountGet() > 0)
// {
// if(true == CAN1_Receive(&rxCanMsg))
// {
// if(rxCanMsg.msgId == 0x108)
//{
// Your code
txCanMsg.msgId = 0x220;
txCanMsg.field.idType = CAN_FRAME_STD;
txCanMsg.field.frameType = CAN_FRAME_DATA;
txCanMsg.field.dlc = CAN_DLC_8;
//txCanMsg.data = data;
txCanMsg.data = msgObjData;
CAN1_Transmit(CAN_PRIORITY_HIGH, &txCanMsg);
// }
//}
//}
}
}
}
while(1);
return 0;
}
post edited by vijayakumar.sargunam - 2021/01/21 23:39:12