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.

CCS/IWR1642: IWR1642:some question about CAN translate

Part Number: IWR1642

Tool/software: Code Composer Studio

Hi,

I have asked questions about CAN sending before, but they have not been solved.

I try to send a message object and delete the message object,but a stack error occurred!

My code for CAN send message object is as follows:

u8 mcal_CanSendByte(u8 bCanIndex,u32 uMsgId,CAN_IdType pIdType,u32 uDataLen,u8 pData[8])
{
u8 retVal = 1; /***设置返回值并初始化***/
u8 uDataIdx = 0;
CAN_DCANData uTxData;

memset(&uTxData,0,sizeof(uTxData));

pTxMsgObjectParams.msgIdentifier = uMsgId; /*设置传输消息ID*/

if(pIdType == The_Standard_Frame)
{
pTxMsgObjectParams.xIdFlag = CAN_DCANXidType_11_BIT; /*标准帧标识*/
}
else if(pIdType == The_Extend_Frame)
{
pTxMsgObjectParams.xIdFlag = CAN_DCANXidType_29_BIT; /*扩展帧标识*/
}
/***创建CAN-TX传输消息实体***/
pTxMsgObjHandle = CAN_createMsgObject (s_pCanHandle, 64, &pTxMsgObjectParams,&s_pErrCode);

uTxData.dataLength = uDataLen; /*设置TX传输消息的数据长度*/
for(uDataIdx = 0;uDataIdx < uDataLen;uDataIdx++)
{
uTxData.msgData[uDataIdx] = pData[uDataIdx];/*复制数据*/
}
/***发送通过参数传入的消息对象,并判断是否发送成功:若发送失败则将该消息入队,并修改返回值为0***/
if(0 != CAN_transmitData(pTxMsgObjHandle,&uTxData,&s_pErrCode))
{
retVal = 0; /***发送失败,重设返回值0***/
}
CAN_deleteMsgObject(pTxMsgObjHandle,&s_pErrCode);

}

Did I make a mistake somewhere? If I don't delete the message object after sending (CAN_deleteMsgObject(pTxMsgObjHandle,&s_pErrCode);), the error will not appear and the program will execute!

Please help me.

Thank you,

Yaowei

  • Hi Wei,

    Sorry to hear about your trouble. Have you looked at and tried to execute the CAN driver test provided in the mmWave SDK? In case you're not aware of it, the CAN driver test is available with source code in the  C:\ti\mmwave_sdk_<ver>\packages\ti\drivers\can\test and it includes 4 different tests as shown below:

    1. DCAN Internal loopback test
    2. DCAN External loopback test
    3. DCAN Parity test
    4. DCAN Tx/Rx test

    You can refer to the source code available under C:\ti\mmwave_sdk_<ver>\packages\ti\drivers\can\test\common\main.c, specifically refer to the function dcanLoopbackTest and compare . I have a couple of suggestions for debugging:

    1. Could you try compiling your code without O3 optimization in case you have it enabled and see if that fixes the issue?

    2. Try adding some delay after calling CAN_transmitData before you call CAN_deleteMsgObject.

    Let me know if the above helps.

    Regards

    -Nitin

  • Hi Wei,

    Do you have any update on the above?

    Thanks
    -Nitin
  • Closing this thread due to lack of activity. Please open a new thread if you have more questions.

    Regards
    -Nitin