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.

AWR1642: Data transfer over CAN network

Part Number: AWR1642

Hi guys,

I am trying to send data over the CAN network. I am using 2 AWR1642 devices, one sends the data over CAN other receive the data .

I connected CAN high pin to CAN high pin of the other device, CAN low pin to CAN low pin of the other device and ground to ground.

When I call the function CAN_transmitData().  I am not getting any error, but at receiver side I am not able to receive the data.

But interrupt enable field I made it 1(i.e interrupts are enabled), but call back function is not getting called.Please help me .

  • Hello Suraj,

    You will need to do a couple of hardware modifications on the AWR1642BOOST for the external CAN communication to work.

    The CAN and SPI lines are muxed together, so you will need to do below modifications to get the CAN communication working.

    You can also refer to the below post that has been answered in past with similar issue:

    You can refer to AWR1642BOOST schematic and assembly files here to find the placement of the resistors on the EVM.

    With these modification you should be able to get the CAN communication working .

    Thanks,

    Raghu

  • Is it like these resistors I have to re solder , or is this can be done directly on the soc using some jumpers and all please let me know sir.
  • Hello Suraj,

    This would require you to solder 0 ohm resistors.

    -Raghu
  • AWR1642 EVM just gives the CANFD port, so you need to choose the CANFD function.
  • Hello Raghu,
    We mounted 0 ohm on R11 and R12 and we removed R6 and R4. Still data is not going. I am not getting interrupt call back after the Tx done.
    I am using CAN not CAN FD
  • Is it not possible to use CAN instead of CANFD ???
  • Hello Suraj,

    You can use the CAN-FD interface in the Classic CAN mode by setting the frametype to CANFD_MCANFrameType_CLASSIC .

    Please see the below post for the modification to be done for the CANFD interface to work in CLASSIC CAN mode.
    e2e.ti.com/.../2316239

    Could you please confirm how are you analysing the CAN data ? What analyzer you are using ?

    -Raghu
  • Is it possible to use both CAN and SPI connections togather??
  • Suraj,

    The CAN and SPI are muxed . So you can use only 1 of the interfaces with particular mux settings.
    Both the interfaces cannot be used together.

    -Raghu
  • I am using a CAN - Ethernet converter which receives data in the CAN port and sends the data over Ethernet. I changed frame type to CANFD_MCANFrameType_CLASSIC.
    CANFD_transmitData() function is in a loop, only for the 1st transmission I am getting proper return value but no TxComplete interrupt generated.
    In the next loop I am getting the error CANFD_EINUSE error. Please help me in solving the problem.
  • Suraj,
    You can introduce either a delay (Task_sleep())or retry the transmission in case of an Tx error.

    -Raghu
  • Suraj,
    With the changes I mentioned above , do you still see the issue?

    Please post the code changes you have made for transmitting the data over the CAN so that I can check if there are issue with your changes.

    Thanks,
    Raghu
  • Ya still I am getting the error CANFD_EINUSE.

    This is the code I am using.
    /*MCAN config parameters*/
    mcanCfgParams->fdMode = 0x1U;
    mcanCfgParams->brsEnable = 0x1U;
    mcanCfgParams->txpEnable = 0x0U;
    mcanCfgParams->efbi = 0x0U;
    mcanCfgParams->pxhddisable = 0x0U;
    mcanCfgParams->darEnable = 0x1U;
    mcanCfgParams->wkupReqEnable = 0x1U;
    mcanCfgParams->autoWkupEnable = 0x1U;
    mcanCfgParams->emulationEnable = 0x0U;
    mcanCfgParams->emulationFAck = 0x0U;
    mcanCfgParams->clkStopFAck = 0x0U;
    mcanCfgParams->wdcPreload = 0x0U;
    mcanCfgParams->tdcEnable = 0x1U;
    mcanCfgParams->tdcConfig.tdcf = 0U;
    mcanCfgParams->tdcConfig.tdco = 8U;
    mcanCfgParams->monEnable = 0x0U;
    mcanCfgParams->asmEnable = 0x0U;
    mcanCfgParams->tsPrescalar = 0x0U;
    mcanCfgParams->tsSelect = 0x0U;
    mcanCfgParams->timeoutSelect = CANFD_MCANTimeOutSelect_CONT;
    mcanCfgParams->timeoutPreload = 0x0U;
    mcanCfgParams->timeoutCntEnable = 0x0U;
    mcanCfgParams->filterConfig.rrfe = 0x1U;
    mcanCfgParams->filterConfig.rrfs = 0x1U;
    mcanCfgParams->filterConfig.anfe = 0x1U;
    mcanCfgParams->filterConfig.anfs = 0x1U;
    mcanCfgParams->msgRAMConfig.lss = 127U;
    mcanCfgParams->msgRAMConfig.lse = 64U;
    mcanCfgParams->msgRAMConfig.txBufNum = 32U;
    mcanCfgParams->msgRAMConfig.txFIFOSize = 0U;
    mcanCfgParams->msgRAMConfig.txBufMode = 0U;
    mcanCfgParams->msgRAMConfig.txEventFIFOSize = 0U;
    mcanCfgParams->msgRAMConfig.txEventFIFOWaterMark = 0U;
    mcanCfgParams->msgRAMConfig.rxFIFO0size = 0U;
    mcanCfgParams->msgRAMConfig.rxFIFO0OpMode = 0U;
    mcanCfgParams->msgRAMConfig.rxFIFO0waterMark = 0U;
    mcanCfgParams->msgRAMConfig.rxFIFO1size = 64U;
    mcanCfgParams->msgRAMConfig.rxFIFO1waterMark = 64U;
    mcanCfgParams->msgRAMConfig.rxFIFO1OpMode = 64U;
    mcanCfgParams->eccConfig.enable = 1;
    mcanCfgParams->eccConfig.enableChk = 1;
    mcanCfgParams->eccConfig.enableRdModWr = 1;
    mcanCfgParams->errInterruptEnable = 1U;
    mcanCfgParams->dataInterruptEnable = 1U;
    mcanCfgParams->appErrCallBack = MCANAppErrStatusCallback;
    mcanCfgParams->appDataCallBack = MCANAppCallback;

    /* Initialize the CANFD driver */
    canHandle = CANFD_init(&mcanCfgParams, &errCode);
    if (canHandle == NULL)
    {
    System_printf ("Error: CANFD Module Initialization failed [Error code %d]\n", errCode);
    return -1;
    }

    mcanBitTimingParams.nomBrp = 0x2U;
    mcanBitTimingParams.nomPropSeg = 0x8U;
    mcanBitTimingParams.nomPseg1 = 0x6U;
    mcanBitTimingParams.nomPseg2 = 0x5U;
    mcanBitTimingParams.nomSjw = 0x1U;

    mcanBitTimingParams.dataBrp = 0x1U;
    mcanBitTimingParams.dataPropSeg = 0x2U;
    mcanBitTimingParams.dataPseg1 = 0x2U;
    mcanBitTimingParams.dataPseg2 = 0x3U;
    mcanBitTimingParams.dataSjw = 0x1U;

    /* Configure the CAN driver */
    retVal = CANFD_configBitTime (canHandle, &mcanBitTimingParams, &errCode);
    if (retVal < 0)
    {
    System_printf ("Error: CANFD Module configure bit time failed [Error code %d]\n", errCode);
    return -1;
    }
    /* Setup the transmit message object */
    txMsgObjectParams.direction = CANFD_Direction_TX;
    txMsgObjectParams.msgIdType = CANFD_MCANXidType_29_BIT;
    txMsgObjectParams.msgIdentifier = 0xC1;

    txMsgObjHandle = CANFD_createMsgObject (canHandle, &txMsgObjectParams, &errCode);
    if (txMsgObjHandle == NULL)
    {
    System_printf ("Error: CANFD create Tx message object failed [Error code %d]\n", errCode);
    return -1;
    }

    retVal = CANFD_transmitData (txMsgObjHandle, txMsgObjectParams.msgIdentifier, CANFD_MCANFrameType_CLASSIC, 1U, &txData[0], &errCode);
    if (retVal < 0)
    {
    System_printf("Error in sending the Data over CAN FD Error code:%d\n",errCode);
    return -1;

    }
  • Hello Suraj,

    This is just cut /paste from the SDK driver code.
    Hope you are doing initialization only once and then calling "CANFD_transmitData ()" in your transmit thread. Is this understanding correct?


    -Raghu
  • Please tell me what to do???
  • Hello Suraj,

    You can follow the below procedure:
    1) Include the CAN initialization code in "MmwDemo_mssInitTask()" . You can include the pinmux, data structure initialization and message object creation in this task.

    2) Your CAN transmit code should be there in "MmwDemo_mboxReadTask()" where you receive the object data from the DSS. You can include the "CANFD_transmitData()" in place of the "UART_writePolling()" . Just make sure you send the right length and data pointer.

    Thanks,
    Raghu
  • Ya I am doing like that only...
  • From the code you have put in this post did not look like that.

    Also curious to know why you are just transferring 1byte data using the CAN_Transmit(). Is there a specific reason to transfer 1byte at a time ?

    -Raghu
  • I did the same thing still I am getting the error with error code -3502
  • Suraj,

    Why are you transferring just 1 byte ?

    -Raghu
  • No just to check I tried
  • I tried to send 64 byte it did not work so I sent 1 byte to try no specific reason for it.
    But still my problem did not got solved.
  • Suraj,

    My suggestion would be to understand the CAN interface and the amount of data you can transfer .

    Please refer to the AWR1642 TRM  "Section 21 Modular Controller Area Network (MCAN)" .

    Please try and understand the interface before you try to include it in your design.

    Thanks,

    Raghu