Other Parts Discussed in Thread: C2000WARE
Dear team:
When a customer of mine was conducting CAN communication test, there was no problem sending data, but when receiving, the data could not be received. And from CCS expressions, you can see that sRXCANMessage.ui32MsgLen will change from 8 to 0.
When single-stepping, it is found that when the judgment statement that accepts data in the function CANMessageGet() is executed, the program will jump directly to the else statement. And "ui32MsgCtrl = HWREG(ui32Base + CAN_O_IF2MCTL);" is only related to the CAN_O_IF2MCTL control register. This register is only set to 0 during initialization, and there is no other operation afterwards. Should CAN_O_IF2MCTL be set first? How should it be set up?
if(ui32MsgCtrl & CAN_IF2MCTL_NEWDAT)
{
// Get the amount of data needed to be read.
pMsgObject->ui32MsgLen = (ui32MsgCtrl & CAN_IF2MCTL_DLC_M);
// Don't read any data for a remote frame, there is nothing valid in
// that buffer anyway.
if((pMsgObject->ui32Flags & MSG_OBJ_REMOTE_FRAME) == 0)
{
// Read out the data from the CAN registers.
CANDataRegRead(pMsgObject->pucMsgData,
(uint32_t *)(ui32Base + CAN_O_IF2DATA),
pMsgObject->ui32MsgLen);
}
// Now clear out the new data flag.
HWREGH(ui32Base + CAN_O_IF2CMD + 2) = CAN_IF2CMD_TXRQST >> 16;
// Transfer the message object to the message object specified by
// ui32ObjID.
HWREGH(ui32Base + CAN_O_IF2CMD) = ui32ObjID & CAN_IF2CMD_MSG_NUM_M;
// Wait for busy bit to clear
while(HWREGH(ui32Base + CAN_O_IF2CMD) & CAN_IF2CMD_BUSY)
{
}
// Indicate that there is new data in this message.
pMsgObject->ui32Flags |= MSG_OBJ_NEW_DATA;
}
else
{
// Along with the MSG_OBJ_NEW_DATA not being set the amount of data
// needs to be set to zero if none was available.
pMsgObject->ui32MsgLen = 0;
}
Best regards