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.

TDA3XEVM: How to receive multi-ID using DCAN Demo?

Part Number: TDA3XEVM
Other Parts Discussed in Thread: SYSBIOS

Hi VIvek,

Could you help me solve the following problem? 

I want to receive multi-ID CAN messages(0x500~0x51F) and follow your instructions below.

1. "system_dcan.c" changes
- Change 'ENABLE_B2B_DCAN_TEST' value to '1', this is to take DCAN out of loopback mode
- In 'System_dcanInitCfgStruct()', change 'dcanConfig->rxMsgId' to '0x500'
2. "utils_dcan.c" changes
- In 'Utils_dcanInitDefaultMbx2MsgIdMap()', change 'dcanMbx2MsgIdMap[0].msgId' to '0x500'
- In 'Utils_dcanInitRxMsgObjParams()', change 'pDcanRxCfgPrms->msgIdentifierMask' to '0x1F03FFFF'

And print message ID in "system_dcan.c" as below

static Void System_dcanRxMsgHandler(dcanMsg_t *rxMsg)
{

...

Vps_printf("Id[0x%X] \n",rxMsg->appMsgPrms.rxMsgIdentifier>>18U);

...

}

After compilation, I ran the program but it crashed, and show following information.

[IPU1-1] 10.923168 s: Id[0x500]
[IPU1-1] 10.923930 s: Id[0x501]
[IPU1-1] 10.924693 s: Id[0x502]
[IPU1-1] 10.925150 s: Assertion @ Line: 400 in /ssd1/ethan/vsdk3.2/vision_sdk/apps/src/rtos/modules/dcan/utils_dcan.c: status == 0 : failed !!!
[IPU1-1] 10.925333 s:
[IPU1-1] 10.925364 s: ### XDC ASSERT - ERROR CALLBACK START ###
[IPU1-1] 10.925425 s:
[IPU1-1] 10.925547 s: assertion failure: A_badContext: bad calling context. See GateMutex API doc for details.
[IPU1-1] 10.925638 s:
[IPU1-1] 10.925669 s: ### XDC ASSERT - ERROR CALLBACK END ###
[IPU1-1] 10.925760 s:
[IPU1-1] 10.926005 s: ti.sysbios.gates.GateMutex: line 99: ti.sysbios.gates.GateMutex: line 99: assertion failure: A_badContext: bad calling context. See GateMutex API doc for details.
[IPU1-1] 10.926218 s: xdc.runtime.Error.raise: terminating execution

I reverted pDcanRxCfgPrms->msgIdentifierMask to default value(0x1FFFFFFF), then the program can work, but message ID only shows "0x500" continuously.

This problem is urgent to me. I would like to express my sincere thanks to you.

Best Regards,

Ethan Liao

  • Hi Ethan,

    Currently Vivek is out of office and will be back early next week. Kindly expect some delay in reply.

    Regards,
    Rishabh
  • Hi Ethan,

    If you revert back the change for 'pDcanRxCfgPrms->msgIdentifierMask', you will only receive the message with ID:0x500.
    Can you step through the function call 'Utils_queGet()' at line no.399 in the file 'utils_dcan.c' and see where exactly it is failing?

    Thanks & Regards,
    Vivek Dhande.
    Texas Instruments (India) Pvt Ltd
  • Hi VIvek,

    I found it is failed in "utils_que.c" at line no.506(status = SYSTEM_LINK_STATUS_EFAIL;).


    Int32 Utils_queGet(Utils_QueHandle * handle, Ptr * data,
    UInt32 minCount, UInt32 timeout)
    {
    ...
    if (timeout == BSP_OSAL_NO_WAIT)
    {
    doBreak = (Bool)TRUE; /* non-blocking
    * function call,
    * exit with error
    */
    status = SYSTEM_LINK_STATUS_EFAIL; //line no.506
    }
    else
    if (handle->flags & UTILS_QUE_FLAG_BLOCK_QUE_GET)
    {
    ...
    ...
    }

    But i don't know why it failed.
    Could you help me fix this problem step by step, please?

    Best Regards,
    Ethan Liao
  • Hi VIvek,

    I don't know why "status" return -1 at line no.506 in "utils_que.c" and cause failure.
    Could you teach me how to solve this problem, please?
    I am looking forward to your reply. Thank you very much.

    Best Regards,
    Ethan Liao
  • Hi Ethan,

    Can you add following modifications on top of yours and share the logs?

    Add following in 'Utils_dcanRxIsrCb()' API in 'utils_dcan.c' just before 'Utils_dcanQueGet()' API call at line no.1729:
    Vps_printf(" UTILS DCAN : Free Q count: %d, Rx msg Q count: %d",
    Utils_queGetQueuedCount(&dcanRxMsgObj->freeQ.handle),
    Utils_queGetQueuedCount(&dcanRxMsgObj->rxMsgQ[rxMbxIndex].handle) );


    Thanks & Regards,
    Vivek Dhande.
    Texas Instruments (India) Pvt Ltd
  • Hi Vivek ,

    The logs show below.

    [IPU1-1] 13.616360 s: UTILS DCAN : Free Q count: 4, Rx msg Q count: 0
    [IPU1-1] 13.616513 s: Msg Id[0x500]
    [IPU1-1] 13.616604 s: UTILS DCAN : Free Q count: 3, Rx msg Q count: 0
    [IPU1-1] 13.616879 s: UTILS DCAN : Free Q count: 2, Rx msg Q count: 1
    [IPU1-1] 13.617153 s: UTILS DCAN : Free Q count: 1, Rx msg Q count: 2
    [IPU1-1] 13.617458 s: Msg Id[0x501]
    [IPU1-1] 13.617672 s: UTILS DCAN : Free Q count: 1, Rx msg Q count: 2
    [IPU1-1] 13.617916 s: UTILS DCAN : Free Q count: 0, Rx msg Q count: 3
    [IPU1-1] 13.618068 s: Assertion @ Line: 401 in /ssd1/ethan/vsdk3.2/vision_sdk/apps/src/rtos/modules/dcan/utils_dcan.c: status == 0 : failed !!!
    [IPU1-1] 13.618221 s:
    [IPU1-1] 13.618282 s: ### XDC ASSERT - ERROR CALLBACK START ###
    [IPU1-1] 13.618343 s:
    [IPU1-1] 13.618465 s: assertion failure: A_badContext: bad calling context. See GateMutex API doc for details.
    [IPU1-1] 13.618556 s:
    [IPU1-1] 13.618587 s: ### XDC ASSERT - ERROR CALLBACK END ###
    [IPU1-1] 13.618648 s:
    [IPU1-1] 13.618922 s: ti.sysbios.gates.GateMutex: line 99: ti.sysbios.gates.GateMutex: line 99: assertion failure: A_badContext: bad calling context. See GateMutex API doc for details.
    [IPU1-1] 13.619136 s: xdc.runtime.Error.raise: terminating execution

    Best Regards,
    Ethan Liao
  • Hi Ethan,

    Thanks for providing the prints/logs.
    It looks like your program is not able to consume the messages at the rate at which it is receiving i.e. 'freeQ' is empty when ISR is called(same can be seen in the above logs).
    This could be happening because of following reasons:
    1. Due to high system load, 'Utils_dcanRxTsk' is not getting chance to run and consume the message from 'rxMsgQ'.
    2. Due to low priority of 'Utils_dcanRxTsk', some other task(with high priority) is running and 'Utils_dcanRxTsk' is not getting change to run. Thus resulting in the same.

    Please do/share following:
    1. Please share CPU(on which DCAN application is running) load. Just make sure it not high.
    2. Enable task entry and exit hooks. Print info/name of the currently executing function.
    3. What is the configured baud rate of DCAN?
    4. At what rate messages are being received by DCAN on TDA3xx?
    5. Increase the size of 'freeQ' and 'dcanQueMsgs' to '50' and re-run the same use-case. Share the logs for the same.

    Just make sure that there is no other interrupt which is blocking the execution of the 'Utils_dcanRxTsk'.

    Thanks & Regards,
    Vivek Dhande.
    Texas Instruments (India) Pvt Ltd
  • Hi Vivek ,

    Thanks for your help. The problem has been fixed by following changes.
    1. Increase the size of 'freeQ' and 'dcanQueMsgs' in 'utils_dcan.c'
    2. in 'system_dcan.c',
    change 'dcanConfig->enableSendRxAck' and 'dcanConfig->enableReceiveRxAck' to FALSE
    change 'dcanConfig->rxAckMsgCb' to NULL


    Besides, there is one thing I want to make sure .
    If I want to change the range of received ID(0x4E0~0x5FF), are following modifications right?
    in 'system_dcan.c'
    - In 'System_dcanInitCfgStruct()', change 'dcanConfig->rxMsgId' to '0x4E0'
    in 'utils_dcan.c'
    - In 'Utils_dcanInitDefaultMbx2MsgIdMap()', change 'dcanMbx2MsgIdMap[0].msgId' to '0x4E0'
    - In 'Utils_dcanInitRxMsgObjParams()', change 'pDcanRxCfgPrms->msgIdentifierMask' to '0x1803FFFF'

    Could you help me check above steps, please?
    Thank you so much for your prompt reply.

    Best Regards,
    Ethan Liao
  • Hi Ethan,

    Good to know that your problem is resolved now.
    With your configuration, you will also receive a message with ID '0x400' which is not desired as per your requirement.
    You cannot receive above range of IDs(i.e. 0x4E0~0x5FF) into a single mailbox. You need to configure 2 mailboxes. One for the range 0x4E0~0x4FF
    and another for 0x500~0x5FF.

    Thanks & Regards,
    Vivek Dhande.
    Texas Instruments (India) Pvt Ltd
  • Hi Vivek ,

    Although my program can receive multi-ID now,  some IDs seem missing.

    Transmitting end repeat sending 0x500~0x51F in order ,  but receiving end can't get all IDs. Please refer to the attachment.

    Could you teach me how to modify this problem step by step, please?

    Best Regards,

    Ethan Liao

    4E0 0x1803FFFF.log

  • Hi Ethan,

    This could happen because, some of messages transmitted could be dropped by DCAN. This typically happens when mailbox in which incoming message is supposed to be filled/stored is already occupied by previous message i.e. SW has not read this message yet.
    When some of messages are dropped, are you able to see any errors towards transmitter side for those missing messages?

    At what rate messages are being received by DCAN on TDA3xx? Is it still at 1 Mbps?
    And are you sending these messages back to back w/o any duration in between then i.e. 100% bus load?

    Thanks & Regards,
    Vivek Dhande.
    Texas Instruments (India) Pvt Ltd

  • Hi Vivek,

    we can't see any error message, and our CAN bus bit rate is 500kbps,
    and just one device transmission data, TDA3xx received and analysis data,
    so I don't think the bus is busy.

    Jackie
  • Hi Jackie,

    Are you sending messages from transmitter w/o any interval? If yes, then can you try giving some delay between transmission of two consecutive message and see if messages are still dropped?

    Thanks & Regards,
    Vivek Dhande.
    Texas Instruments (India) Pvt Ltd
  • Hi Jackie,

    I haven't heard back from you, I'm assuming you were able to resolve your issue.
    If not, just post a reply below (or create a new thread if the thread has locked due to time-out).

    Thanks & Regards,
    Vivek Dhande.
    Texas Instruments (India) Pvt Ltd