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.

IWR1843: Classical CAN transmission

Part Number: IWR1843
Other Parts Discussed in Thread: IWR6843, SYSBIOS,

I am using classical CAN transmission under CANFD, but the data received by my CAN analyzer is wrong. Why?

  • Hello

    Can you please provide more information  in order to guide with debug. Please list what have you tried SW and what is expected data wise.

    Have you tried any of the CAN driver tests provided in the SDK release.

    Thank you,

    Vaibhav

  • I had to test the classic CAN with the CANFD driver.
    This part of the code needs to be compatible with the IWR6843 program, so you must use the CANFD driver.
    I write the code according to the CANFD test in SDK, and the Settings are all consistent.
    Why does this happen?

  • Hi,

    Could you please provide more details how you are configuring CANFD driver for CAN mode.

    Are you implementing range RX object ?

    Thanks

    Yogesh

  • /*Intialize CANFD configuration parameters. */
    memset(mcanCfgParams, sizeof(CANFD_MCANInitParams), 0);
    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 = sblErrStatusCallback;
    mcanCfgParams->appDataCallBack = sblDataCallback;


    /* Setup the PINMUX to bring out the XWR18xx CAN pins */
    Pinmux_Set_OverrideCtrl(SOC_XWR18XX_PINE14_PADAE, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL);
    Pinmux_Set_FuncSel(SOC_XWR18XX_PINE14_PADAE, SOC_XWR18XX_PINE14_PADAE_CANFD_TX);

    Pinmux_Set_OverrideCtrl(SOC_XWR18XX_PIND13_PADAD, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL);
    Pinmux_Set_FuncSel(SOC_XWR18XX_PIND13_PADAD, SOC_XWR18XX_PIND13_PADAD_CANFD_RX);
    /* Initialize the CANFD driver. */
    canHandle = CANFD_init(0U,&mcanCfgParams[0], &errCode);
    if (canHandle == NULL)
    {
    SBL_printf("Error: CANFD Module Initialization failed [Error code %d]\n",errCode);
    return ;
    }

    /* Configure the bit timing parameters. */
    mcanBitTimingParams.nomBrp = 0x2U;
    mcanBitTimingParams.nomPropSeg = 0x8U;
    mcanBitTimingParams.nomPseg1 = 0x6U;
    mcanBitTimingParams.nomPseg2 = 0x5U;
    mcanBitTimingParams.nomSjw = 0x1U;
    mcanBitTimingParams.dataBrp = 0x2U;
    mcanBitTimingParams.dataPropSeg = 0x8U;
    mcanBitTimingParams.dataPseg1 = 0x6U;
    mcanBitTimingParams.dataPseg2 = 0x5U;
    mcanBitTimingParams.dataSjw = 0x1U;
    retVal = CANFD_configBitTime(canHandle, &mcanBitTimingParams, &errCode);

    retVal = CANFD_transmitData (txMsgObjHandle, txMsgObjectParams.msgIdentifier, CANFD_MCANFrameType_CLASSIC, 8 , &txdata[0], &errCode);

    ti_sysbios_knl_Task_sleep(2);

  • Quick question:

    IWR1843 has CAN (DCAN) too. Any reason you want to use CANFD (MCAN) for CAN instead of DCAN.

    Thanks

    Yogesh 

  • As I said, this code will also be used on IWR6843, so CANFD must be used.
    Please tell me what the problem is.
    Or your CANFD Classic CAN cannot be received with ordinary CAN analyzer.

  • For CANFD Vs Classic CAN mode,  please disable these:

    mcanCfgParams->fdMode = 0x0U;
    mcanCfgParams->brsEnable = 0x0U;
    mcanCfgParams->darEnable = 0x0U;

  • I have made the modification as you said, but I still cannot receive the data.
    Is there anything else that needs to be set for using classic can?
    In addition, I saw optionTLV when I checked the test you wrote. Do I need to set it when I use classic can?

  • I printed the message of the sending function from the serial port, and found that the return value of the first frame was -1, and from the second frame, I returned -3502 error each time.
    Why is that?

    int32_t errCode, retVal;

    /*Intialize CANFD configuration parameters. */
    memset(mcanCfgParams, sizeof(CANFD_MCANInitParams), 0);
    mcanCfgParams->fdMode = 0x0U;
    mcanCfgParams->brsEnable = 0x0U;
    mcanCfgParams->txpEnable = 0x0U;
    mcanCfgParams->efbi = 0x0U;
    mcanCfgParams->pxhddisable = 0x0U;
    mcanCfgParams->darEnable = 0x0U;
    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 = sblErrStatusCallback;
    mcanCfgParams->appDataCallBack = sblDataCallback;


    /* Setup the PINMUX to bring out the XWR18xx CAN pins */
    Pinmux_Set_OverrideCtrl(SOC_XWR18XX_PINE14_PADAE, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL);
    Pinmux_Set_FuncSel(SOC_XWR18XX_PINE14_PADAE, SOC_XWR18XX_PINE14_PADAE_CANFD_TX);

    Pinmux_Set_OverrideCtrl(SOC_XWR18XX_PIND13_PADAD, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL);
    Pinmux_Set_FuncSel(SOC_XWR18XX_PIND13_PADAD, SOC_XWR18XX_PIND13_PADAD_CANFD_RX);
    /* Initialize the CANFD driver. */
    canHandle = CANFD_init(0U,&mcanCfgParams[0], &errCode);
    if (canHandle == NULL)
    {
    SBL_printf("Error: CANFD Module Initialization failed [Error code %d]\n",errCode);
    return ;
    }

    /* Configure the bit timing parameters. */
    mcanBitTimingParams.nomBrp = 0x2U;
    mcanBitTimingParams.nomPropSeg = 0x8U;
    mcanBitTimingParams.nomPseg1 = 0x6U;
    mcanBitTimingParams.nomPseg2 = 0x5U;
    mcanBitTimingParams.nomSjw = 0x1U;

    mcanBitTimingParams.dataBrp = 0x2U;
    mcanBitTimingParams.dataPropSeg = 0x8U;
    mcanBitTimingParams.dataPseg1 = 0x6U;
    mcanBitTimingParams.dataPseg2 = 0x5U;
    mcanBitTimingParams.dataSjw = 0x1U;
    retVal = CANFD_configBitTime(canHandle, &mcanBitTimingParams, &errCode);
    if (retVal < 0)
    {
    SBL_printf("Error: CANFD Module configure bit time failed [Error code %d]\n",errCode);
    return ;
    }
    /* Setup the handshake message object and wait for a message to check if the meta image has to
    be updated or auto boot should resume. */
    rxMsgObjectParams.direction = CANFD_Direction_RX;
    rxMsgObjectParams.msgIdType = CANFD_MCANXidType_11_BIT;
    rxMsgObjectParams.msgIdentifier = SBL_CANFD_DATA_MSG_ID;
    rxMsgObjHandle = CANFD_createMsgObject(canHandle, &rxMsgObjectParams,&errCode);
    if (rxMsgObjHandle == NULL)
    {
    SBL_printf("Error: CANFD create Rx message object failed [Error code %d]\n",errCode);
    return ;
    }
    /*********Update meta image message object has been received. Proceed with downloading the image and writing to flash. *******/
    /* Setup the receive message object for receiving data packets. */
    rxMsgObjectParams.direction = CANFD_Direction_RX;
    rxMsgObjectParams.msgIdType = CANFD_MCANXidType_11_BIT;
    rxMsgObjectParams.msgIdentifier = SBL_CANFD_DATA_MSG_ID;
    rxMsgObjHandle = CANFD_createMsgObject(canHandle, &rxMsgObjectParams, &errCode);
    if (rxMsgObjHandle == NULL)
    {
    SBL_printf("Error: CANFD create Rx message object failed [Error code %d]\n",errCode);
    return ;
    }
    /* Setup the receive message object for receiving terminate packets. */
    rxMsgObjectParams.direction = CANFD_Direction_RX;
    rxMsgObjectParams.msgIdType = CANFD_MCANXidType_11_BIT;
    rxMsgObjectParams.msgIdentifier = SBL_CANFD_TERMINATE_MSG_ID;
    rxMsgObjHandle = CANFD_createMsgObject(canHandle, &rxMsgObjectParams,&errCode);
    if (rxMsgObjHandle == NULL)
    {
    SBL_printf("Error: CANFD create Rx message object failed [Error code %d]\n",errCode);
    return ;
    }


    /* Setup the transmit message object */
    txMsgObjectParams.direction = CANFD_Direction_TX;
    txMsgObjectParams.msgIdType = CANFD_MCANXidType_29_BIT;
    txMsgObjectParams.msgIdentifier = 0x29E;

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

    retVal = CANFD_transmitData (txMsgObjHandle, txMsgObjectParams.msgIdentifier, CANFD_MCANFrameType_CLASSIC, 8 , &txdata[0], &errCode);

    ti_sysbios_knl_Task_sleep(10);

  • Hi,

    I'm not sure how to fix your exact problem, but I have implemented classical can transmission over canfd on a iwr6843 chip on Mistral's board. I added the following code to the mmwave demo code to send the detected object data. I can't seem to get can receive working though. Hope it helps.

    /**************************************************************************
     *************************** Global Definitions ***************************
     **************************************************************************/
    volatile uint32_t gTxDoneFlag = 0, gRxDoneFlag = 0, gParityErrFlag = 0;
    volatile uint32_t gTxPkts = 0, gRxPkts = 0, gErrStatusInt = 0;
    volatile uint32_t iterationCount = 0U;
    uint32_t dataLength = 0U;
    uint32_t msgLstErrCnt = 0U;
    uint32_t gDisplayStats = 0;
    uint8_t rxData[64U];
    uint32_t txDataLength, rxDataLength;
    // CANFD_MCANFrameType frameType = CANFD_MCANFrameType_FD;
    CANFD_MCANFrameType frameType = CANFD_MCANFrameType_CLASSIC;
    static void MCANAppInitParams(CANFD_MCANInitParams *mcanCfgParams);
    CANFD_Handle canHandle;
    CANFD_MsgObjHandle txMsgObjHandle;
    CANFD_MCANMsgObjCfgParams txMsgObjectParams;
    uint8_t canInstanceId = 0;


    /**************************************************************************
     *************************** Can functions ***************************
     **************************************************************************/

    static int32_t PlatformInit(void)
    {
        /* Setup the PINMUX to bring out the XWR68xx CANFD pins */
        Pinmux_Set_OverrideCtrl(SOC_XWR68XX_PINE14_PADAE, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL);
        Pinmux_Set_FuncSel(SOC_XWR68XX_PINE14_PADAE, SOC_XWR68XX_PINE14_PADAE_CANFD_TX);

        Pinmux_Set_OverrideCtrl(SOC_XWR68XX_PIND13_PADAD, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL);
        Pinmux_Set_FuncSel(SOC_XWR68XX_PIND13_PADAD, SOC_XWR68XX_PIND13_PADAD_CANFD_RX);

        /* Setup the PINMUX to bring out the XWR68xx CANFD-2 pins */
        Pinmux_Set_OverrideCtrl(SOC_XWR68XX_PINE15_PADAG, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL);
        Pinmux_Set_FuncSel(SOC_XWR68XX_PINE15_PADAG, SOC_XWR68XX_PINE15_PADAG_CANFD2_TX);

        Pinmux_Set_OverrideCtrl(SOC_XWR68XX_PINE13_PADAF, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL);
        Pinmux_Set_FuncSel(SOC_XWR68XX_PINE13_PADAF, SOC_XWR68XX_PINE13_PADAF_CANFD2_RX);


        // Set gpio_1 up to select canfd mux for can on mistral module
        Pinmux_Set_OverrideCtrl(SOC_XWR68XX_PINJ13_PADAC, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL);
        Pinmux_Set_FuncSel(SOC_XWR68XX_PINJ13_PADAC, SOC_XWR68XX_PINJ13_PADAC_GPIO_1);
        GPIO_setConfig (SOC_XWR68XX_GPIO_1, GPIO_CFG_OUTPUT);

        // //write low to gpio_1
        GPIO_write (SOC_XWR68XX_GPIO_1, 0U);

        return 0;
    }

    void Can_Initalize(void)
    {
        int32_t errCode = 0;
        int32_t retVal = 0;
        CANFD_MCANInitParams mcanCfgParams;
        CANFD_MCANBitTimingParams mcanBitTimingParams;
        CANFD_MCANMsgObjCfgParams rxMsgObjectParams;
        CANFD_MsgObjHandle rxMsgObjHandle;
        gTxDoneFlag = 0;
        gRxDoneFlag = 0;
        /* Setup the PINMUX to bring out the XWR16xx CAN pins */
        PlatformInit();

        /* Configure the divide value for MCAN source clock */
        SOC_setPeripheralClock(gMmwMssMCB.socHandle, SOC_MODULE_MCAN, SOC_CLKSOURCE_VCLK, 4U, &errCode);
        /* Initialize peripheral memory */
        SOC_initPeripheralRam(gMmwMssMCB.socHandle, SOC_MODULE_MCAN, &errCode);

        MCANAppInitParams(&mcanCfgParams);
        /* Initialize the CANFD driver */
        canHandle = CANFD_init(canInstanceId, &mcanCfgParams, &errCode);
        if (canHandle == NULL)
        {
            System_printf("Error: CANFD Module Initialization failed [Error code %d]\n", errCode);
            return;
        }
        /* Configuring 1Mbps and 5Mbps as nominal and data bit-rate respectively
        Prop seg: 8
        Ph seg 1: 6
        Ph Seg2 : 5
        Sync jump: 1
        BRP(Baud rate Prescaler): 2
        Nominal Bit rate = (40)/(((8+6+5)+1)*BRP) = 1Mhz
        Timing Params for Data Bit rate:
        Prop seg: 2
        Ph seg 1: 2
        Ph Seg2 : 3
        Sync jump: 1
        BRP(Baud rate Prescaler): 1
        Nominal Bit rate = (40)/(((2+2+3)+1)*BRP) = 5Mhz
        */
        mcanBitTimingParams.nomBrp      = 0x2U;
        mcanBitTimingParams.nomPropSeg  = 0x8U;
        mcanBitTimingParams.nomPseg1    = 0x6U;
        mcanBitTimingParams.nomPseg2    = 0x5U;
        mcanBitTimingParams.nomSjw      = 0x1U;

        /*5MHz*/
        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;
        }
        /* Setup the transmit message object */
        txMsgObjectParams.direction = CANFD_Direction_TX;
        txMsgObjectParams.msgIdType = CANFD_MCANXidType_29_BIT;
        txMsgObjectParams.msgIdentifier = 0xD1;
        txMsgObjHandle = CANFD_createMsgObject(canHandle, &txMsgObjectParams, &errCode);
        if (txMsgObjHandle == NULL)
        {
            System_printf("Error: CANFD create Tx message object failed [Error code %d]\n",
                          errCode);
            return;
        }
        /* Setup the receive message object */
        rxMsgObjectParams.direction = CANFD_Direction_RX;
        rxMsgObjectParams.msgIdType = CANFD_MCANXidType_29_BIT;
        rxMsgObjectParams.msgIdentifier = 0xD1;
        rxMsgObjHandle = CANFD_createMsgObject(canHandle, &rxMsgObjectParams, &errCode);
        if (rxMsgObjHandle == NULL)
        {
            System_printf("Error: CANFD create Rx message object failed [Error code %d]\n",
                          errCode);
            return;
        }
    }

    static void MCANAppCallback(CANFD_MsgObjHandle handle, CANFD_Reason reason)
    {
        int32_t errCode, retVal;
        uint32_t id;
        CANFD_MCANFrameType rxFrameType;
        CANFD_MCANXidType rxIdType;
        if (reason == CANFD_Reason_TX_COMPLETION)
        {
            {
                gTxPkts++;
                gTxDoneFlag = 1;
                return;
            }
        }
        if (reason == CANFD_Reason_RX)
        {
            {
                /* Reset the receive buffer */
                memset(&rxData, 0, sizeof(rxData));
                dataLength = 0;
                retVal = CANFD_getData(handle, &id, &rxFrameType, &rxIdType, &rxDataLength,
                                       &rxData[0], &errCode);
                if (retVal < 0)
                {
                    System_printf ("Error: CAN receive data for iteration %d failed [Error code %d]\n", iterationCount, errCode);
                    return;
                }
                if (rxFrameType != frameType)
                {
                    System_printf ("Error: CAN received incorrect frame type Sent %d Received %d for iteration %d failed\n", frameType, rxFrameType, iterationCount);
                    return;
                }
                /* Validate the data */
                gRxPkts++;
                gRxDoneFlag = 1;
                return;
            }
        }
        if (reason == CANFD_Reason_TX_CANCELED)
        {
            {
                gTxPkts++;
                gTxDoneFlag = 1;
                gRxDoneFlag = 1;
                return;
            }
        }
    }

    static void MCANAppErrStatusCallback(CANFD_Handle handle, CANFD_Reason reason,
                                         CANFD_ErrStatusResp *errStatusResp)
    {
        /*Record the error count */
        gErrStatusInt++;
        return;
    }

    static void MCANAppInitParams(CANFD_MCANInitParams *mcanCfgParams)
    {
        /*Intialize MCAN Config Params*/
        memset(mcanCfgParams, sizeof(CANFD_MCANInitParams), 0);

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

    int32_t Can_Transmit_Schedule( uint32_t msg_id,
                uint8_t *txmsg, uint32_t len)
    {

        volatile uint32_t                     index = 0;
        int32_t                     retVal = 0;
        int32_t                     errCode = 0;
        
        //System_printf ("MEssage %x  len %d\n", msg_id, len);
        if(frameType == CANFD_MCANFrameType_FD)
        {
            Task_sleep(1);
        
            while(len > 64U)
            {
                retVal = CANFD_transmitData (txMsgObjHandle, msg_id, CANFD_MCANFrameType_FD, 64U, &txmsg[index], &errCode);
                index = index + 64U;
                len = len - 64U;
                
                Task_sleep(1);
            }
            retVal = CANFD_transmitData (txMsgObjHandle, msg_id, CANFD_MCANFrameType_FD, len, &txmsg[index], &errCode);
        }
        else
        {
            while(len > 8U)
            {
                retVal = CANFD_transmitData (txMsgObjHandle, msg_id, CANFD_MCANFrameType_CLASSIC, 8U, &txmsg[index], &errCode);
                if (retVal < 0)
                {
                    
                    continue;
                }
                index = index + 8U;
                len = len - 8U;
                
            }
            
            retVal = CANFD_transmitData (txMsgObjHandle, msg_id, CANFD_MCANFrameType_CLASSIC, len, &txmsg[index], &errCode);
            
            while(retVal < 0)
            {
                //System_printf("Debug: Error transmitting CAN data %x , Errcode %x\n", retVal, errCode);
                retVal = CANFD_transmitData (txMsgObjHandle, msg_id, CANFD_MCANFrameType_CLASSIC, len, &txmsg[index], &errCode);
                
            }
            
        }
        
        
        return retVal;
        
    }

  • Hi,

    Error -3502 mean the CAN is in use. Could you please confirm you are initializing MCAN clock:

     SOC_setPeripheralClock(gSblMCB.socHandle, SOC_MODULE_MCAN, SOC_CLKSOURCE_VCLK, 4U, &errCode);

     

    Thanks

    Yogesh

  • Thank you very much for your advice.
    After I add this statement, the CAN analyzer can receive the data.
    But this error occurred again when I changed the pin Settings to apply the code to IWR6843.
    The error code returned is -3502. How to set the SOC_setperipheralclock on IWR6843?
    thank you

  • Hi,

    Is this resolved. If you are still facing issue, you need to share your code so that we can re-create your issue.

    Thanks

    Yogesh

  • At present, I am still debugging. If there are any new problems, I will contact you. Thanks for your help!

  • Hi,

    I will close this thread. If you need help you can open new thread.

    Thanks

    Yogesh