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.

TMS320F28377SCAN通讯接收不到数据,并将数据长度置为0,应如何对CAN_O_IF2MCTL进行设置?

Other Parts Discussed in Thread: C2000WARE

在进行CAN通讯时,发送数据没有问题,但是接收时,接收不到数据,且从CCS观察窗看到sRXCANMessage.ui32MsgLen会从设置的8置0,所以进行单步运行,发现当执行到函数CANMessageGet()下接受数据的判断语句时,直接跳至else语句,而ui32MsgCtrl = HWREG(ui32Base + CAN_O_IF2MCTL);只与CAN_O_IF2MCTL控制寄存器有关,这个寄存器只在初始化时置0,后续没有其他操作,是否应先给 CAN_O_IF2MCTL进行设置?应该如何设置?请问一下,有没有遇到过类似问题?

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;
}