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/AWR1642: I can't use CANFD in Type_FD.

Part Number: AWR1642


Tool/software: Code Composer Studio

When I use CANFD in Type_CLASSIC, I use PCAN with this Bit Rate. (Nominal Bit rate = 1M Hz)

I can receive data from AWR1642.

But

When I use CANFD in Type_FD, I use PCAN with this Bit Rate. (Nominal Bit rate = 1M Hz; Data Bit rate = 5M Hz)

I can't receive data from AWR1642.

I just change

from CANFD_MCANFrameType testFrameType = CANFD_MCANFrameType_CLASSIC;

to     CANFD_MCANFrameType testFrameType = CANFD_MCANFrameType_FD;

What is my negligence?

  • It is the Bit Rate in AWR1642.

  • Hello JuiYang Chi,

    There are couple of hardware modification to be done in the AWR1642BOOST for the external CAN communication to work .

    Please see the below post that mentions the hardware ECO's to be done on the AWR1642BOOST for external CAN communication.

    Thanks,

    Raghu

  • I have removed R4 and R6 and mounted R11 and R12.

    When I use CANFD with testFrameType = CANFD_MCANFrameType_CLASSIC
    It is OK for PCAN and AWR1642.
    They all can receive/transmit each other.

    But When I use CANFD with testFrameType = CANFD_MCANFrameType_FD.
    They can't receive/transmit each other.

    Below is my bit rate in PCAN.



    And below is the logs from the CCS debug  
    when I use CANFD with testFrameType = CANFD_MCANFrameType_FD.

    ----------------------------------------------------------------------------------------------------

    Debug: Number of iterations : 1
    Debug: Number of messages transmitted : 0
    Debug: Number of messages received : 0
    Debug: Number of messages lost : 0
    Debug: Error Status Interrupt : 1


    Debug: Message Identifier : 193
    Debug: Direction : Transmit
    Debug: Number of interrupts received : 0
    Debug: Number of messages processed : 1


    Debug: Message Identifier : 194
    Debug: Direction : Receive
    Debug: Number of interrupts received : 0
    Debug: Number of messages processed : 0


    Debug: Receive passive status : 0
    Debug: Transmit Error Counter : 8
    Debug: Receive Error Counter : 0
    Debug: Error Logging Counter : 0


    Debug: LEC : 7
    Debug: Activity : 1
    Debug: Error Passive : 0
    Debug: Warning Status : 0
    Debug: Bus Off Status : 0
    Debug: Data Phase LEC : 3
    Debug: Rx ESI flag : 0
    Debug: Rx BRS flag : 0
    Debug: Rx CAN FD : 0
    Debug: Protocol Exception Event : 0
    Debug: TDC value : 13


    Debug: Number of iterations : 2
    Debug: Number of messages transmitted : 0
    Debug: Number of messages received : 0
    Debug: Number of messages lost : 0
    Debug: Error Status Interrupt : 2


    Debug: Message Identifier : 193
    Debug: Direction : Transmit
    Debug: Number of interrupts received : 0
    Debug: Number of messages processed : 2


    Debug: Message Identifier : 194
    Debug: Direction : Receive
    Debug: Number of interrupts received : 0
    Debug: Number of messages processed : 0


    Debug: Receive passive status : 0
    Debug: Transmit Error Counter : 16
    Debug: Receive Error Counter : 0
    Debug: Error Logging Counter : 0


    Debug: LEC : 7
    Debug: Activity : 1
    Debug: Error Passive : 0
    Debug: Warning Status : 0
    Debug: Bus Off Status : 0
    Debug: Data Phase LEC : 3
    Debug: Rx ESI flag : 0
    Debug: Rx BRS flag : 0
    Debug: Rx CAN FD : 0
    Debug: Protocol Exception Event : 0
    Debug: TDC value : 13

    -----------------------------------------------------------------------------------

    Do I still need to change what in main.c(C:\ti\mmwave_sdk_01_01_00_02\packages\ti\drivers\canfd\test\xwr16xx)?

  • Hello JuiYang Chi,

    Have you selected the CAN-FD option in the PCAN ? If you do not select it, the CANFD frames will not be received/transmitted.

    -Raghu
  • Hi Raghu:

    Yes, I have chosen CANFD on PCAN.

    But it say below

    This is my code.

    /*
     *   @file  main.c
     *
     *   @brief
     *      Unit Test code for CANFD
     *
     *  \par
     *  NOTE:
     *      (C) Copyright 2016 Texas Instruments, Inc.
     *
     *  Redistribution and use in source and binary forms, with or without
     *  modification, are permitted provided that the following conditions
     *  are met:
     *
     *    Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     *    Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the
     *    distribution.
     *
     *    Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     */
    
    /**************************************************************************
     *************************** Include Files ********************************
     **************************************************************************/
    
    /* Standard Include Files. */
    #include <stdint.h>
    #include <stdlib.h>
    #include <stddef.h>
    #include <string.h>
    #include <stdio.h>
    #include <math.h>
    
    /* BIOS/XDC Include Files. */
    #include <xdc/std.h>
    #include <xdc/cfg/global.h>
    #include <xdc/runtime/IHeap.h>
    #include <xdc/runtime/System.h>
    #include <xdc/runtime/Error.h>
    #include <xdc/runtime/Memory.h>
    #include <ti/sysbios/BIOS.h>
    #include <ti/sysbios/knl/Task.h>
    #include <ti/sysbios/knl/Event.h>
    #include <ti/sysbios/knl/Semaphore.h>
    #include <ti/sysbios/knl/Clock.h>
    #include <ti/sysbios/heaps/HeapBuf.h>
    #include <ti/sysbios/heaps/HeapMem.h>
    #include <ti/sysbios/knl/Event.h>
    #include <ti/sysbios/family/arm/v7a/Pmu.h>
    
    /* mmWave SK Include Files: */
    #include <ti/common/sys_common.h>
    #include <ti/drivers/soc/soc.h>
    #include <ti/drivers/canfd/canfd.h>
    #include <ti/drivers/pinmux/pinmux.h>
    #include <ti/drivers/esm/esm.h>
    #include <ti/utils/testlogger/logger.h>
    #include <ti/drivers/osal/HwiP.h>
    
    /**************************************************************************
     *************************** Global Definitions ***************************
     **************************************************************************/
    
    /** \brief Number of messages sent */
    #define MCAN_APP_TEST_INTERNAL_LOOPBACK 1
    #define MCAN_APP_TEST_EXTERNAL_LOOPBACK 2
    #define MCAN_APP_TEST_PARITY            3
    #define MCAN_APP_TEST_EXTERNAL_DATA     4
    #define MCAN_APP_TEST_EVM_EVM           5
    #define MCAN_APP_TEST_TX_CANCEL         6
    #define MCAN_APP_TEST_POWERDOWN         7
    
    #define MCAN_APP_TEST_EVM_MODE_TX       1
    #define MCAN_APP_TEST_EVM_MODE_RX       2
    
    /** \brief Number of messages sent */
    #define MCAN_APP_TEST_MESSAGE_COUNT     100
    
    /* Global Variables */
    volatile uint32_t       testSelection = MCAN_APP_TEST_EXTERNAL_DATA;
    volatile uint32_t       gTxDoneFlag = 0, gRxDoneFlag = 0;
    uint32_t                iterationCount = 0U;
    volatile uint32_t       gTxPkts = 0, gRxPkts = 0, gErrStatusInt = 0;
    uint8_t                 rxData[64U];
    uint32_t                txDataLength, rxDataLength, testDataLength = 0U;
    uint32_t                msgLstErrCnt = 0U;
    uint32_t                dataMissMatchErrCnt = 0U;
    uint32_t                rxTicks[MCAN_APP_TEST_MESSAGE_COUNT];
    uint32_t                txTicks[MCAN_APP_TEST_MESSAGE_COUNT];
    uint32_t                minRxTicks;
    uint32_t                maxRxTicks;
    uint32_t                minTxTicks;
    uint32_t                maxTxTicks;
    uint32_t                totalTxTicks;
    uint32_t                totalRxTicks;
    uint8_t                 txData[64U] =
    {0xA1, 0x1A, 0xFF, 0xFF, 0xC1, 0x1C, 0xB1, 0x1B,
    0xA2, 0x2A, 0xFF, 0xFF, 0xC2, 0x2C, 0xB2, 0x2B,
    0xA3, 0x3A, 0xFF, 0xFF, 0xC3, 0x3C, 0xB3, 0x3B,
    0xA4, 0x4A, 0xFF, 0xFF, 0xC4, 0x4C, 0xB4, 0x4B,
    0xA5, 0x5A, 0xFF, 0xFF, 0xC5, 0x5C, 0xB5, 0x5B,
    0xA6, 0x6A, 0xFF, 0xFF, 0xC6, 0x6C, 0xB6, 0x6B,
    0xA7, 0x7A, 0xFF, 0xFF, 0xC7, 0x7C, 0xB7, 0x7B,
    0xA8, 0x8A, 0xFF, 0xFF, 0xC8, 0x8C, 0xB8, 0x8B};
    
    uint32_t                gDisplayStats = 0;
    uint32_t                MCANMode = 1;
    CANFD_MCANFrameType     testFrameType = CANFD_MCANFrameType_FD;
    // CANFD_MCANFrameType     testFrameType = CANFD_MCANFrameType_CLASSIC;
    
    /**
     *  @b Description
     *  @n
     *      This function starts the PMU counter.
     *
     *   @param[in] counter
     *      Counter id used for benchmarking
     *
     *  @retval
     *      Not Applicable.
     */
    void Test_benchmarkStart(uint32_t counter)
    {
        /* Initialize counter to count cycles */
        Pmu_configureCounter(counter, 0x11, FALSE);
    
        /* Reset PMU counter */
        Pmu_resetCount(counter);
    
        /* Start PMU counter */
        Pmu_startCounter(counter);
    }
    
    /**
     *  @b Description
     *  @n
     *      This function stops a PMU counter and returns the current
     *      counter value.
     *
     *   @param[in] counter
     *      Counter id used for benchmarking
     *
     *  @retval
     *      Current PMU counter value.
     */
    uint32_t Test_benchmarkStop(uint32_t counter)
    {
        /* Stop PMU counter */
        Pmu_stopCounter(counter);
    
        /* Read PMU counter */
        return (Pmu_getCount(counter));
    }
    
    /**
     *  @b Description
     *  @n
     *      Application implemented callback function to handle error and status interrupts.
     *
     *   @param[in] handle
     *      Handle to the CANFD Driver
     *  @param[in]  reason
     *      Cause of the interrupt which prompted the callback.
     *  @param[in]  errStatusResp
     *      Response structure populated with the value of the fields that caused the error or status interrupt.
     *      Processing of this structure is dependent on the callback reason.
     *
     *  @retval
     *      Not Applicable.
     */
    static void MCANAppErrStatusCallback(CANFD_Handle handle, CANFD_Reason reason, CANFD_ErrStatusResp* errStatusResp)
    {
        gErrStatusInt++;
    
        return;
    }
    
    /**
     *  @b Description
     *  @n
     *      Application implemented callback function to handle Tx complete and receive interrupts.
     *
     *   @param[in] handle
     *      Handle to the message object
     *   @param[in] reason
     *      Cause of the interrupt which prompted the callback.
     *
     *  @retval
     *      Not Applicable.
     */
    static void MCANAppCallback(CANFD_MsgObjHandle handle, CANFD_Reason reason)
    {
        int32_t                 errCode, retVal;
        uint32_t                id;
        CANFD_MCANFrameType     rxFrameType = testFrameType;
        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));
                testDataLength = 0;
    
                if ((testSelection != MCAN_APP_TEST_EXTERNAL_DATA) && (gRxPkts < MCAN_APP_TEST_MESSAGE_COUNT))
                {
                    /* Reset the counter: */
                    Test_benchmarkStart(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;
                }
                txData[0]=rxData[0];
                txData[1]=rxData[1];
                txData[2]=rxData[2];
                txData[3]=rxData[3];
    
                if (rxFrameType != testFrameType)
                {
                    System_printf ("Error: CAN received incorrect frame type Sent %d Received %d for iteration %d failed\n", testFrameType, rxFrameType, iterationCount);
                    return;
                }
    
                if ((testSelection != MCAN_APP_TEST_EXTERNAL_DATA) && (gRxPkts < MCAN_APP_TEST_MESSAGE_COUNT))
                {
                    /* Stop the counter: */
                    rxTicks[gRxPkts] = Test_benchmarkStop(0);
    
                    /* Update the receive statistics: */
                    minRxTicks   = (minRxTicks < rxTicks[gRxPkts]) ? minRxTicks : rxTicks[gRxPkts];
                    maxRxTicks   = (maxRxTicks > rxTicks[gRxPkts]) ? maxRxTicks : rxTicks[gRxPkts];
                    totalRxTicks = totalRxTicks + rxTicks[gRxPkts];
                }
    
                /* Validate the data */
                if ((testSelection == MCAN_APP_TEST_INTERNAL_LOOPBACK) || (testSelection == MCAN_APP_TEST_EXTERNAL_LOOPBACK) ||
                                (testSelection == MCAN_APP_TEST_EVM_EVM))
                {
                    /* Check if sent data has been received */
                    if (rxDataLength == txDataLength)
                    {
                        while (testDataLength < rxDataLength)
                        {
                            if (rxData[testDataLength] != txData[testDataLength])
                            {
                                dataMissMatchErrCnt++;
                                System_printf ("Error: CAN receive data mismatch for iteration %d at byte %d\n", iterationCount, testDataLength);
                            }
                            testDataLength++;
                        }
                    }
    
                }
                gRxPkts++;
                gRxDoneFlag = 1;
                return;
            }
        }
        if (reason == CANFD_Reason_TX_CANCELED)
        {
            {
                gTxPkts++;
                gTxDoneFlag = 1;
                gRxDoneFlag = 1;
                return;
            }
        }
    
    }
    
    /**
     *  @b Description
     *  @n
     *      Platform specific intializations.
     *
     *  @retval
     *      Success     - 0
     *  @retval
     *      Error       - <0
     */
    
    static int32_t PlatformInit(void)
    {
        /* Setup the PINMUX to bring out the XWR16xx CAN pins */
        Pinmux_Set_OverrideCtrl(SOC_XWR16XX_PINE14_PADAE, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL);
        Pinmux_Set_FuncSel(SOC_XWR16XX_PINE14_PADAE, SOC_XWR16XX_PINE14_PADAE_CANFD_TX);
    
        Pinmux_Set_OverrideCtrl(SOC_XWR16XX_PIND13_PADAD, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL);
        Pinmux_Set_FuncSel(SOC_XWR16XX_PIND13_PADAD, SOC_XWR16XX_PIND13_PADAD_CANFD_RX);
    
        return 0;
    }
    
    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;
    
        if (testSelection == MCAN_APP_TEST_PARITY)
        {
            mcanCfgParams->eccConfig.enable         = 1;
            mcanCfgParams->eccConfig.enableChk      = 1;
            mcanCfgParams->eccConfig.enableRdModWr  = 1;
        }
        else
        {
            mcanCfgParams->eccConfig.enable         = 1;
            mcanCfgParams->eccConfig.enableChk      = 1;
            mcanCfgParams->eccConfig.enableRdModWr  = 1;
        }
    
        mcanCfgParams->errInterruptEnable   = 1U;
        mcanCfgParams->dataInterruptEnable  = 1U;
        mcanCfgParams->appErrCallBack       = MCANAppErrStatusCallback;
        mcanCfgParams->appDataCallBack      = MCANAppCallback;
    }
    
    static int32_t mcanLoopbackTest()
    {
        CANFD_Handle                canHandle;
        CANFD_MsgObjHandle          txMsgObjHandle;
        CANFD_MsgObjHandle          rxMsgObjHandle;
        int32_t                     retVal = 0;
        int32_t                     errCode = 0;
        CANFD_OptionTLV             optionTLV;
        uint8_t                     value;
        CANFD_MCANInitParams        mcanCfgParams;
        CANFD_MCANBitTimingParams   mcanBitTimingParams;
        CANFD_MCANMsgObjCfgParams   txMsgObjectParams;
        CANFD_MCANMsgObjCfgParams   rxMsgObjectParams;
        CANFD_MCANLoopbackCfgParams mcanloopbackParams;
        CANFD_MCANMsgObjectStats    msgObjStats;
    
        gTxDoneFlag = 0;
    
        MCANAppInitParams (&mcanCfgParams);
    
        /* 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;
        }
    
        /* 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      = 0x4U;
        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;
        }
    
        mcanloopbackParams.enable = 1;
        if (testSelection == MCAN_APP_TEST_INTERNAL_LOOPBACK)
            mcanloopbackParams.mode = CANFD_MCANLoopBackMode_INTERNAL;
        else
            mcanloopbackParams.mode = CANFD_MCANLoopBackMode_EXTERNAL;
    
        optionTLV.type = CANFD_Option_MCAN_LOOPBACK;
        optionTLV.length = sizeof(CANFD_MCANLoopbackCfgParams);
        optionTLV.value = (void*) &mcanloopbackParams;
    
        retVal =  CANFD_setOptions(canHandle, &optionTLV, &errCode);
        if (retVal < 0)
        {
            System_printf ("Error: CANFD set option Loopback 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 = 0x29E;
    
        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;
        }
    
        /* Setup the receive message object */
        rxMsgObjectParams.direction = CANFD_Direction_RX;
        rxMsgObjectParams.msgIdType = CANFD_MCANXidType_29_BIT;
        rxMsgObjectParams.msgIdentifier = 0x29E;
    
        rxMsgObjHandle = CANFD_createMsgObject (canHandle, &rxMsgObjectParams, &errCode);
        if (rxMsgObjHandle == NULL)
        {
            System_printf ("Error: CANFD create Rx message object failed [Error code %d]\n", errCode);
            return -1;
        }
    
        /* Initialize the measurement counters */
        minRxTicks   = 0xFFFFFFFFU;
        maxRxTicks   = 0U;
        minTxTicks   = 0xFFFFFFFFU;
        maxTxTicks   = 0U;
        totalTxTicks = 0U;
        totalRxTicks = 0U;
    
        while (iterationCount != MCAN_APP_TEST_MESSAGE_COUNT)
        {
            /* Reset the counter: */
            Test_benchmarkStart(0);
    
            if (testSelection == MCAN_APP_TEST_TX_CANCEL)
            {
                /* Cancel data over Tx message object */
                retVal = CANFD_transmitDataCancel (txMsgObjHandle, &errCode);
                if (retVal < 0)
                {
                    System_printf ("Error: CANFD transmit data cancel for iteration %d failed [Error code %d]\n", iterationCount, errCode);
                    return -1;
                }
            }
            else
            {
                /* Send data over Tx message object */
                if (testFrameType == CANFD_MCANFrameType_FD)
                    retVal = CANFD_transmitData (txMsgObjHandle, txMsgObjectParams.msgIdentifier, CANFD_MCANFrameType_FD, 64U, &txData[0], &errCode);
                else
                    retVal = CANFD_transmitData (txMsgObjHandle, txMsgObjectParams.msgIdentifier, CANFD_MCANFrameType_CLASSIC, 64U, &txData[0], &errCode);
    
                if (retVal < 0)
                {
                    System_printf ("Error: CANFD transmit data for iteration %d failed [Error code %d]\n", iterationCount, errCode);
                    return -1;
                }
            }
            /* Stop the counter: */
            txTicks[iterationCount] = Test_benchmarkStop(0);
    
            /* Update the transmit statistics: */
            minTxTicks   = (minTxTicks < txTicks[iterationCount]) ? minTxTicks : txTicks[iterationCount];
            maxTxTicks   = (maxTxTicks > txTicks[iterationCount]) ? maxTxTicks : txTicks[iterationCount];
            totalTxTicks = totalTxTicks + txTicks[iterationCount];
    
            while (gTxDoneFlag == 0);
            gTxDoneFlag = 0;
    
            while (gRxDoneFlag == 0);
            gRxDoneFlag = 0;
    
            iterationCount++;
        }
    
        System_printf("Debug: Number of iterations              : %d\n", iterationCount);
        System_printf("Debug: Number of messages transmitted    : %d\n", gTxPkts);
        System_printf("Debug: Number of messages received       : %d\n", gRxPkts);
        System_printf("Debug: Number of messages lost           : %d\n", msgLstErrCnt);
        System_printf("Debug: Number of data mismatch           : %d\n", dataMissMatchErrCnt);
        System_printf("Debug: Error Status Interrupt            : %d\n", gErrStatusInt);
        System_printf("\n\n");
    
        msgObjStats.handle = txMsgObjHandle;
        optionTLV.type = CANFD_Option_MCAN_MSG_OBJECT_STATS;
        optionTLV.length = sizeof(CANFD_MCANMsgObjectStats);
        optionTLV.value = (void*) &msgObjStats;
    
        retVal =  CANFD_getOptions(canHandle, &optionTLV, &errCode);
        if (retVal < 0)
        {
            System_printf ("Error: CANFD get stats failed [Error code %d]\n", errCode);
            return -1;
        }
    
        System_printf("Debug: Message Identifier                : %d\n", msgObjStats.msgId);
        System_printf("Debug: Direction                         : %s\n", (msgObjStats.direction == 0) ? "Receive" : "Transmit");
        System_printf("Debug: Number of interrupts received     : %d\n", msgObjStats.interruptsRxed);
        System_printf("Debug: Number of messages processed      : %d\n", msgObjStats.messageProcessed);
        System_printf("\n\n");
    
        msgObjStats.handle = rxMsgObjHandle;
        retVal =  CANFD_getOptions(canHandle, &optionTLV, &errCode);
        if (retVal < 0)
        {
            System_printf ("Error: CANFD get stats failed [Error code %d]\n", errCode);
            return -1;
        }
    
        System_printf("Debug: Message Identifier                : %d\n", msgObjStats.msgId);
        System_printf("Debug: Direction                         : %s\n", (msgObjStats.direction == 0) ? "Receive" : "Transmit");
        System_printf("Debug: Number of interrupts received     : %d\n", msgObjStats.interruptsRxed);
        System_printf("Debug: Number of messages processed      : %d\n", msgObjStats.messageProcessed);
    
        if (testSelection != MCAN_APP_TEST_TX_CANCEL)
        {
            System_printf("Debug: Receive & Transmit Measurements\n");
            System_printf("Debug: Rx Min:%d Max: %d Average:%d ticks\n", minRxTicks, maxRxTicks, totalRxTicks/gTxPkts);
            System_printf("Debug: Tx Min:%d Max: %d Average:%d ticks\n", minTxTicks, maxTxTicks, totalTxTicks/gRxPkts);
        }
        System_printf("\n\n");
    
        /* Reset the driver */
        optionTLV.type = CANFD_Option_MCAN_MODE;
        optionTLV.length = sizeof(uint8_t);
        value = 1U;
        optionTLV.value = (void*) &value;
    
        retVal =  CANFD_setOptions(canHandle, &optionTLV, &errCode);
        if (retVal < 0)
        {
            System_printf ("Error: CANFD set option Mode - SW INIT failed [Error code %d]\n", errCode);
            return -1;
        }
    
        optionTLV.type = CANFD_Option_MCAN_MODE;
        optionTLV.length = sizeof(uint8_t);
        value = 0U;
        optionTLV.value = (void*) &value;
    
        retVal =  CANFD_setOptions(canHandle, &optionTLV, &errCode);
        if (retVal < 0)
        {
            System_printf ("Error: CANFD set option Mode - NORMAL failed [Error code %d]\n", errCode);
            return -1;
        }
    
        retVal = CANFD_deleteMsgObject(txMsgObjHandle, &errCode);
        if (retVal < 0)
        {
            System_printf ("Error: CANFD delete Tx message object failed [Error code %d]\n", errCode);
            return -1;
        }
    
        retVal = CANFD_deleteMsgObject(rxMsgObjHandle, &errCode);
        if (retVal < 0)
        {
            System_printf ("Error: CANFD delete Rx message object failed [Error code %d]\n", errCode);
            return -1;
        }
    
        retVal = CANFD_deinit(canHandle, &errCode);
        if (retVal < 0)
        {
            System_printf ("Error: CANFD deinit failed [Error code %d]\n", errCode);
            return -1;
        }
    
        if ((msgLstErrCnt == 0) && (dataMissMatchErrCnt == 0))
        {
            if (testSelection == MCAN_APP_TEST_INTERNAL_LOOPBACK)
            {
                System_printf("Debug: Internal loopback testing for %d iterations Passed\n", iterationCount);
            }
            else
            {
                System_printf("Debug: External loopback testing for %d iterations Passed\n", iterationCount);
            }
        }
        else
        {
            if (testSelection == MCAN_APP_TEST_INTERNAL_LOOPBACK)
            {
                System_printf("Debug: Internal loopback testing for %d iterations Failed\n", iterationCount);
                retVal = -1;
            }
            else
            {
                System_printf("Debug: External loopback testing for %d iterations Failed\n", iterationCount);
                retVal = -1;
            }
        }
        return retVal;
    }
    
    static int32_t mcanPowerDownTest()
    {
        CANFD_Handle                canHandle;
        CANFD_MsgObjHandle          txMsgObjHandle;
        CANFD_MsgObjHandle          rxMsgObjHandle;
        int32_t                     retVal = 0;
        int32_t                     errCode = 0;
        CANFD_OptionTLV             optionTLV;
        uint8_t                     value;
        CANFD_MCANInitParams        mcanCfgParams;
        CANFD_MCANBitTimingParams   mcanBitTimingParams;
        CANFD_MCANMsgObjCfgParams   txMsgObjectParams;
        CANFD_MCANMsgObjCfgParams   rxMsgObjectParams;
        CANFD_MCANLoopbackCfgParams mcanloopbackParams;
        CANFD_MCANMsgObjectStats    msgObjStats;
    
        gTxDoneFlag = 0;
    
        MCANAppInitParams (&mcanCfgParams);
    
        /* 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;
        }
    
        /* 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      = 0x4U;
        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;
        }
    
        mcanloopbackParams.enable = 1;
        mcanloopbackParams.mode = CANFD_MCANLoopBackMode_EXTERNAL;
    
        optionTLV.type = CANFD_Option_MCAN_LOOPBACK;
        optionTLV.length = sizeof(CANFD_MCANLoopbackCfgParams);
        optionTLV.value = (void*) &mcanloopbackParams;
    
        retVal =  CANFD_setOptions(canHandle, &optionTLV, &errCode);
        if (retVal < 0)
        {
            System_printf ("Error: CANFD set option Loopback failed [Error code %d]\n", errCode);
            return -1;
        }
    
        /* Setup the transmit message object */
        txMsgObjectParams.direction = CANFD_Direction_TX;
        txMsgObjectParams.msgIdType = CANFD_MCANXidType_11_BIT;
        txMsgObjectParams.msgIdentifier = 0x29E;
    
        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;
        }
    
        /* Setup the receive message object */
        rxMsgObjectParams.direction = CANFD_Direction_RX;
        rxMsgObjectParams.msgIdType = CANFD_MCANXidType_11_BIT;
        rxMsgObjectParams.msgIdentifier = 0x29E;
    
        rxMsgObjHandle = CANFD_createMsgObject (canHandle, &rxMsgObjectParams, &errCode);
        if (rxMsgObjHandle == NULL)
        {
            System_printf ("Error: CANFD create Rx message object failed [Error code %d]\n", errCode);
            return -1;
        }
    
        /* Initialize the measurement counters */
        minRxTicks   = 0xFFFFFFFFU;
        maxRxTicks   = 0U;
        minTxTicks   = 0xFFFFFFFFU;
        maxTxTicks   = 0U;
        totalTxTicks = 0U;
        totalRxTicks = 0U;
    
        while (iterationCount != MCAN_APP_TEST_MESSAGE_COUNT)
        {
            /* Reset the counter: */
            Test_benchmarkStart(0);
    
            {
                /* Send data over Tx message object */
                if (testFrameType == CANFD_MCANFrameType_FD)
                    retVal = CANFD_transmitData (txMsgObjHandle, txMsgObjectParams.msgIdentifier, CANFD_MCANFrameType_FD, 64U, &txData[0], &errCode);
                else
                    retVal = CANFD_transmitData (txMsgObjHandle, txMsgObjectParams.msgIdentifier, CANFD_MCANFrameType_CLASSIC, 64U, &txData[0], &errCode);
    
                if (retVal < 0)
                {
                    System_printf ("Error: CANFD transmit data for iteration %d failed [Error code %d]\n", iterationCount, errCode);
                    return -1;
                }
            }
            /* Stop the counter: */
            txTicks[iterationCount] = Test_benchmarkStop(0);
    
            /* Update the transmit statistics: */
            minTxTicks   = (minTxTicks < txTicks[iterationCount]) ? minTxTicks : txTicks[iterationCount];
            maxTxTicks   = (maxTxTicks > txTicks[iterationCount]) ? maxTxTicks : txTicks[iterationCount];
            totalTxTicks = totalTxTicks + txTicks[iterationCount];
    
            while (gTxDoneFlag == 0);
            gTxDoneFlag = 0;
    
            while (gRxDoneFlag == 0);
            gRxDoneFlag = 0;
    
            iterationCount++;
        }
    
        System_printf("Debug: Number of iterations              : %d\n", iterationCount);
        System_printf("Debug: Number of messages transmitted    : %d\n", gTxPkts);
        System_printf("Debug: Number of messages received       : %d\n", gRxPkts);
        System_printf("Debug: Number of messages lost           : %d\n", msgLstErrCnt);
        System_printf("Debug: Number of data mismatch           : %d\n", dataMissMatchErrCnt);
        System_printf("Debug: Error Status Interrupt            : %d\n", gErrStatusInt);
        System_printf("\n\n");
    
        msgObjStats.handle = txMsgObjHandle;
        optionTLV.type = CANFD_Option_MCAN_MSG_OBJECT_STATS;
        optionTLV.length = sizeof(CANFD_MCANMsgObjectStats);
        optionTLV.value = (void*) &msgObjStats;
    
        retVal =  CANFD_getOptions(canHandle, &optionTLV, &errCode);
        if (retVal < 0)
        {
            System_printf ("Error: CANFD get stats failed [Error code %d]\n", errCode);
            return -1;
        }
    
        System_printf("Debug: Message Identifier                : %d\n", msgObjStats.msgId);
        System_printf("Debug: Direction                         : %s\n", (msgObjStats.direction == 0) ? "Receive" : "Transmit");
        System_printf("Debug: Number of interrupts received     : %d\n", msgObjStats.interruptsRxed);
        System_printf("Debug: Number of messages processed      : %d\n", msgObjStats.messageProcessed);
        System_printf("\n\n");
    
        msgObjStats.handle = rxMsgObjHandle;
        retVal =  CANFD_getOptions(canHandle, &optionTLV, &errCode);
        if (retVal < 0)
        {
            System_printf ("Error: CANFD get stats failed [Error code %d]\n", errCode);
            return -1;
        }
    
        System_printf("Debug: Message Identifier                : %d\n", msgObjStats.msgId);
        System_printf("Debug: Direction                         : %s\n", (msgObjStats.direction == 0) ? "Receive" : "Transmit");
        System_printf("Debug: Number of interrupts received     : %d\n", msgObjStats.interruptsRxed);
        System_printf("Debug: Number of messages processed      : %d\n", msgObjStats.messageProcessed);
    
        System_printf("\n\n");
    
        /* Power Down the module */
        optionTLV.type = CANFD_Option_MCAN_POWER_DOWN;
        optionTLV.length = sizeof(uint8_t);
        value = 1U;
        optionTLV.value = (void*) &value;
    
        retVal =  CANFD_setOptions(canHandle, &optionTLV, &errCode);
        if (retVal < 0)
        {
            System_printf ("Error: CANFD set option Power Down failed [Error code %d]\n", errCode);
            return -1;
        }
        else
            System_printf ("Debug: CANFD Module Power Down sucessful\n");
    
        optionTLV.type = CANFD_Option_MCAN_POWER_DOWN;
        optionTLV.length = sizeof(uint8_t);
        value = 0;
        optionTLV.value = (void*) &value;
    
        retVal =  CANFD_setOptions(canHandle, &optionTLV, &errCode);
        if (retVal < 0)
        {
            System_printf ("Error: CANFD set option Wake Up failed [Error code %d]\n", errCode);
            return -1;
        }
        else
            System_printf ("Debug: CANFD Module is Wake Up sucessful\n");
    
        System_printf("\n\n");
    
        iterationCount = 0;
        while (iterationCount != MCAN_APP_TEST_MESSAGE_COUNT)
        {
            /* Reset the counter: */
            Test_benchmarkStart(0);
    
            {
                /* Send data over Tx message object */
                if (testFrameType == CANFD_MCANFrameType_FD)
                    retVal = CANFD_transmitData (txMsgObjHandle, txMsgObjectParams.msgIdentifier, CANFD_MCANFrameType_FD, 64U, &txData[0], &errCode);
                else
                    retVal = CANFD_transmitData (txMsgObjHandle, txMsgObjectParams.msgIdentifier, CANFD_MCANFrameType_CLASSIC, 64U, &txData[0], &errCode);
    
                if (retVal < 0)
                {
                    System_printf ("Error: CANFD transmit data for iteration %d failed [Error code %d]\n", iterationCount, errCode);
                    return -1;
                }
            }
            /* Stop the counter: */
            txTicks[iterationCount] = Test_benchmarkStop(0);
    
            /* Update the transmit statistics: */
            minTxTicks   = (minTxTicks < txTicks[iterationCount]) ? minTxTicks : txTicks[iterationCount];
            maxTxTicks   = (maxTxTicks > txTicks[iterationCount]) ? maxTxTicks : txTicks[iterationCount];
            totalTxTicks = totalTxTicks + txTicks[iterationCount];
    
            while (gTxDoneFlag == 0);
            gTxDoneFlag = 0;
    
            while (gRxDoneFlag == 0);
            gRxDoneFlag = 0;
    
            iterationCount++;
        }
    
        System_printf("\n\n");
        System_printf("Debug: Number of iterations              : %d\n", iterationCount);
        System_printf("Debug: Number of messages transmitted    : %d\n", gTxPkts);
        System_printf("Debug: Number of messages received       : %d\n", gRxPkts);
        System_printf("Debug: Number of messages lost           : %d\n", msgLstErrCnt);
        System_printf("Debug: Number of data mismatch           : %d\n", dataMissMatchErrCnt);
        System_printf("Debug: Error Status Interrupt            : %d\n", gErrStatusInt);
        System_printf("\n\n");
    
        msgObjStats.handle = txMsgObjHandle;
        optionTLV.type = CANFD_Option_MCAN_MSG_OBJECT_STATS;
        optionTLV.length = sizeof(CANFD_MCANMsgObjectStats);
        optionTLV.value = (void*) &msgObjStats;
    
        retVal =  CANFD_getOptions(canHandle, &optionTLV, &errCode);
        if (retVal < 0)
        {
            System_printf ("Error: CANFD get stats failed [Error code %d]\n", errCode);
            return -1;
        }
    
        System_printf("Debug: Message Identifier                : %d\n", msgObjStats.msgId);
        System_printf("Debug: Direction                         : %s\n", (msgObjStats.direction == 0) ? "Receive" : "Transmit");
        System_printf("Debug: Number of interrupts received     : %d\n", msgObjStats.interruptsRxed);
        System_printf("Debug: Number of messages processed      : %d\n", msgObjStats.messageProcessed);
        System_printf("\n\n");
    
        msgObjStats.handle = rxMsgObjHandle;
        retVal =  CANFD_getOptions(canHandle, &optionTLV, &errCode);
        if (retVal < 0)
        {
            System_printf ("Error: CANFD get stats failed [Error code %d]\n", errCode);
            return -1;
        }
    
        System_printf("Debug: Message Identifier                : %d\n", msgObjStats.msgId);
        System_printf("Debug: Direction                         : %s\n", (msgObjStats.direction == 0) ? "Receive" : "Transmit");
        System_printf("Debug: Number of interrupts received     : %d\n", msgObjStats.interruptsRxed);
        System_printf("Debug: Number of messages processed      : %d\n", msgObjStats.messageProcessed);
    
        System_printf("\n\n");
    
        retVal = CANFD_deleteMsgObject(txMsgObjHandle, &errCode);
        if (retVal < 0)
        {
            System_printf ("Error: CANFD delete Tx message object failed [Error code %d]\n", errCode);
            return -1;
        }
    
        retVal = CANFD_deleteMsgObject(rxMsgObjHandle, &errCode);
        if (retVal < 0)
        {
            System_printf ("Error: CANFD delete Rx message object failed [Error code %d]\n", errCode);
            return -1;
        }
    
        retVal = CANFD_deinit(canHandle, &errCode);
        if (retVal < 0)
        {
            System_printf ("Error: CANFD deinit failed [Error code %d]\n", errCode);
            return -1;
        }
    
        if ((msgLstErrCnt != 0) || (dataMissMatchErrCnt != 0))
        {
            System_printf("Debug: Power down testing with data failed\n");
            retVal = -1;
        }
        return retVal;
    }
    
    static int32_t mcanTransmitTest()
    {
        CANFD_Handle                canHandle;
        CANFD_MsgObjHandle          txMsgObjHandle;
        CANFD_MsgObjHandle          rxMsgObjHandle;
        int32_t                     retVal = 0;
        int32_t                     errCode = 0;
        CANFD_OptionTLV             optionTLV;
        CANFD_MCANInitParams        mcanCfgParams;
        CANFD_MCANBitTimingParams   mcanBitTimingParams;
        CANFD_MCANMsgObjCfgParams   txMsgObjectParams;
        CANFD_MCANMsgObjCfgParams   rxMsgObjectParams;
        CANFD_MCANMsgObjectStats    msgObjStats;
        CANFD_MCANErrCntStatus      errCounter;
        CANFD_MCANProtocolStatus    protoStatus;
    
        gTxDoneFlag = 0;
        gRxDoneFlag = 0;
    
        MCANAppInitParams (&mcanCfgParams);
    
        /* 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;
        }
    
        /* 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;
    
        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;
        }
    
        /* Setup the receive message object */
        rxMsgObjectParams.direction = CANFD_Direction_RX;
        rxMsgObjectParams.msgIdType = CANFD_MCANXidType_29_BIT;
        rxMsgObjectParams.msgIdentifier = 0xC2;
    
        rxMsgObjHandle = CANFD_createMsgObject (canHandle, &rxMsgObjectParams, &errCode);
        if (rxMsgObjHandle == NULL)
        {
            System_printf ("Error: CANFD create Rx message object failed [Error code %d]\n", errCode);
            return -1;
        }
    
        while (1)
        {
            /* Send data over Tx message object */
            if (testFrameType == CANFD_MCANFrameType_FD)
                retVal = CANFD_transmitData (txMsgObjHandle, txMsgObjectParams.msgIdentifier, CANFD_MCANFrameType_FD, 64U, &txData[0], &errCode);
            else           // == CANFD_MCANFrameType_CLASSIC
                retVal = CANFD_transmitData (txMsgObjHandle, txMsgObjectParams.msgIdentifier, CANFD_MCANFrameType_CLASSIC, 8U, &txData[0], &errCode);
            if (retVal < 0)
            {
                msgLstErrCnt++;
                continue;
            }
    
            iterationCount++;
    
            if (gDisplayStats == 0)
            // if (gDisplayStats == 1)
            {
                gDisplayStats = 0;
    
                System_printf("Debug: Number of iterations              : %d\n", iterationCount);
                System_printf("Debug: Number of messages transmitted    : %d\n", gTxPkts);
                System_printf("Debug: Number of messages received       : %d\n", gRxPkts);
                System_printf("Debug: Number of messages lost           : %d\n", msgLstErrCnt);
                System_printf("Debug: Error Status Interrupt            : %d\n", gErrStatusInt);
                System_printf("\n\n");
    
                msgObjStats.handle = txMsgObjHandle;
                optionTLV.type = CANFD_Option_MCAN_MSG_OBJECT_STATS;
                optionTLV.length = sizeof(CANFD_MCANMsgObjectStats);
                optionTLV.value = (void*) &msgObjStats;
    
                retVal =  CANFD_getOptions(canHandle, &optionTLV, &errCode);
                if (retVal < 0)
                {
                    System_printf ("Error: CANFD get stats failed [Error code %d]\n", errCode);
                }
    
                System_printf("Debug: Message Identifier                : %d\n", msgObjStats.msgId);
                System_printf("Debug: Direction                         : %s\n", (msgObjStats.direction == 0) ? "Receive" : "Transmit");
                System_printf("Debug: Number of interrupts received     : %d\n", msgObjStats.interruptsRxed);
                System_printf("Debug: Number of messages processed      : %d\n", msgObjStats.messageProcessed);
                System_printf("\n\n");
    
                msgObjStats.handle = rxMsgObjHandle;
                retVal =  CANFD_getOptions(canHandle, &optionTLV, &errCode);
                if (retVal < 0)
                {
                    System_printf ("Error: CANFD get stats failed [Error code %d]\n", errCode);
                }
    
                System_printf("Debug: Message Identifier                : %d\n", msgObjStats.msgId);
                System_printf("Debug: Direction                         : %s\n", (msgObjStats.direction == 0) ? "Receive" : "Transmit");
                System_printf("Debug: Number of interrupts received     : %d\n", msgObjStats.interruptsRxed);
                System_printf("Debug: Number of messages processed      : %d\n", msgObjStats.messageProcessed);
                System_printf("\n\n");
    
                optionTLV.type = CANFD_Option_MCAN_ERROR_COUNTER;
                optionTLV.length = sizeof(CANFD_MCANErrCntStatus);
                optionTLV.value = (void*) &errCounter;
    
                retVal =  CANFD_getOptions(canHandle, &optionTLV, &errCode);
                if (retVal < 0)
                {
                    System_printf ("Error: CANFD get error counter failed [Error code %d]\n", errCode);
                }
    
                System_printf("Debug: Receive passive status            : %d\n", errCounter.rpStatus);
                System_printf("Debug: Transmit Error Counter            : %d\n", errCounter.transErrLogCnt);
                System_printf("Debug: Receive Error Counter             : %d\n", errCounter.recErrCnt);
                System_printf("Debug: Error Logging Counter             : %d\n", errCounter.canErrLogCnt);
                System_printf("\n\n");
    
                optionTLV.type = CANFD_Option_MCAN_PROTOCOL_STATUS;
                optionTLV.length = sizeof(CANFD_MCANProtocolStatus);
                optionTLV.value = (void*) &protoStatus;
    
                retVal =  CANFD_getOptions(canHandle, &optionTLV, &errCode);
                if (retVal < 0)
                {
                    System_printf ("Error: CANFD get protocol status failed [Error code %d]\n", errCode);
                }
    
                System_printf("Debug: LEC                               : %d\n", protoStatus.lastErrCode);
                System_printf("Debug: Activity                          : %d\n", protoStatus.act);
                System_printf("Debug: Error Passive                     : %d\n", protoStatus.errPassive);
                System_printf("Debug: Warning Status                    : %d\n", protoStatus.warningStatus);
                System_printf("Debug: Bus Off Status                    : %d\n", protoStatus.busOffStatus);
                System_printf("Debug: Data Phase LEC                    : %d\n", protoStatus.dlec);
                System_printf("Debug: Rx ESI flag                       : %d\n", protoStatus.resi);
                System_printf("Debug: Rx BRS flag                       : %d\n", protoStatus.rbrs);
                System_printf("Debug: Rx CAN FD                         : %d\n", protoStatus.rfdf);
                System_printf("Debug: Protocol Exception Event          : %d\n", protoStatus.pxe);
                System_printf("Debug: TDC value                         : %d\n", protoStatus.tdcv);
                System_printf("\n\n");
            }
        }
    }
    
    static int32_t mcanEVM_EVMTest()
    {
        CANFD_Handle                canHandle;
        CANFD_MsgObjHandle          txMsgObjHandle;
        CANFD_MsgObjHandle          rxMsgObjHandle;
        int32_t                     retVal = 0;
        int32_t                     errCode = 0;
        CANFD_OptionTLV             optionTLV;
        CANFD_MCANInitParams        mcanCfgParams;
        CANFD_MCANBitTimingParams   mcanBitTimingParams;
        CANFD_MCANMsgObjCfgParams   txMsgObjectParams;
        CANFD_MCANMsgObjCfgParams   rxMsgObjectParams;
        CANFD_MCANMsgObjectStats    msgObjStats;
        CANFD_MCANErrCntStatus      errCounter;
        CANFD_MCANProtocolStatus    protoStatus;
    
        gTxDoneFlag = 0;
        gRxDoneFlag = 0;
    
        MCANAppInitParams (&mcanCfgParams);
    
        /* 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;
        }
    
        /* 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;
    
        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;
        }
    
        /* Initialize the measurement counters */
        minRxTicks   = 0xFFFFFFFFU;
        maxRxTicks   = 0U;
        minTxTicks   = 0xFFFFFFFFU;
        maxTxTicks   = 0U;
        totalTxTicks = 0U;
        totalRxTicks = 0U;
    
        /* Set the EVM in transmit mode*/
        if (MCANMode == MCAN_APP_TEST_EVM_MODE_TX)
        {
            /* 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;
            }
    
            /* Send data over Tx message object */
            if (testFrameType == CANFD_MCANFrameType_FD)
                retVal = CANFD_transmitData (txMsgObjHandle, txMsgObjectParams.msgIdentifier, CANFD_MCANFrameType_FD, 64U, &txData[0], &errCode);
            else
                retVal = CANFD_transmitData (txMsgObjHandle, txMsgObjectParams.msgIdentifier, CANFD_MCANFrameType_CLASSIC, 64U, &txData[0], &errCode);
            if (retVal < 0)
            {
                //System_printf ("Error: CANFD transmit data for iteration %d failed [Error code %d]\n", iterationCount, errCode);
                return -1;
            }
            /* Wait for the transmit complete interrupt */
            while (gTxDoneFlag == 0);
            gTxDoneFlag = 0;
    
            System_printf("Debug: Number of iterations              : %d\n", iterationCount);
            System_printf("Debug: Number of messages transmitted    : %d\n", gTxPkts);
            System_printf("Debug: Number of messages received       : %d\n", gRxPkts);
            System_printf("Debug: Number of messages lost           : %d\n", msgLstErrCnt);
            System_printf("Debug: Error Status Interrupt            : %d\n", gErrStatusInt);
            System_printf("\n\n");
    
            msgObjStats.handle = txMsgObjHandle;
            optionTLV.type = CANFD_Option_MCAN_MSG_OBJECT_STATS;
            optionTLV.length = sizeof(CANFD_MCANMsgObjectStats);
            optionTLV.value = (void*) &msgObjStats;
    
            retVal =  CANFD_getOptions(canHandle, &optionTLV, &errCode);
            if (retVal < 0)
            {
                System_printf ("Error: CANFD get stats failed [Error code %d]\n", errCode);
            }
    
            System_printf("Debug: Message Identifier                : %d\n", msgObjStats.msgId);
            System_printf("Debug: Direction                         : %s\n", (msgObjStats.direction == 0) ? "Receive" : "Transmit");
            System_printf("Debug: Number of interrupts received     : %d\n", msgObjStats.interruptsRxed);
            System_printf("Debug: Number of messages processed      : %d\n", msgObjStats.messageProcessed);
            System_printf("\n\n");
        }
    
        /* Set the EVM in transmit mode*/
        if (MCANMode == MCAN_APP_TEST_EVM_MODE_RX)
        {
            /* Setup the receive message object */
            rxMsgObjectParams.direction = CANFD_Direction_RX;
            rxMsgObjectParams.msgIdType = CANFD_MCANXidType_29_BIT;
            rxMsgObjectParams.msgIdentifier = 0xC1;
    
            rxMsgObjHandle = CANFD_createMsgObject (canHandle, &rxMsgObjectParams, &errCode);
            if (rxMsgObjHandle == NULL)
            {
                System_printf ("Error: CANFD create Rx message object failed [Error code %d]\n", errCode);
                return -1;
            }
    
            /* Wait for the packet to arrive */
            while (gRxDoneFlag == 0);
            gRxDoneFlag = 0;
    
            msgObjStats.handle = rxMsgObjHandle;
            optionTLV.type = CANFD_Option_MCAN_MSG_OBJECT_STATS;
            optionTLV.length = sizeof(CANFD_MCANMsgObjectStats);
            optionTLV.value = (void*) &msgObjStats;
    
            retVal =  CANFD_getOptions(canHandle, &optionTLV, &errCode);
            if (retVal < 0)
            {
                System_printf ("Error: CANFD get stats failed [Error code %d]\n", errCode);
            }
    
            System_printf("Debug: Message Identifier                : %d\n", msgObjStats.msgId);
            System_printf("Debug: Direction                         : %s\n", (msgObjStats.direction == 0) ? "Receive" : "Transmit");
            System_printf("Debug: Number of interrupts received     : %d\n", msgObjStats.interruptsRxed);
            System_printf("Debug: Number of messages processed      : %d\n", msgObjStats.messageProcessed);
            System_printf("\n\n");
    
            optionTLV.type = CANFD_Option_MCAN_ERROR_COUNTER;
            optionTLV.length = sizeof(CANFD_MCANErrCntStatus);
            optionTLV.value = (void*) &errCounter;
    
            retVal =  CANFD_getOptions(canHandle, &optionTLV, &errCode);
            if (retVal < 0)
            {
                System_printf ("Error: CANFD get error counter failed [Error code %d]\n", errCode);
            }
    
            System_printf("Debug: Receive passive status            : %d\n", errCounter.rpStatus);
            System_printf("Debug: Transmit Error Counter            : %d\n", errCounter.transErrLogCnt);
            System_printf("Debug: Receive Error Counter             : %d\n", errCounter.recErrCnt);
            System_printf("Debug: Error Logging Counter             : %d\n", errCounter.canErrLogCnt);
            System_printf("\n\n");
    
            optionTLV.type = CANFD_Option_MCAN_PROTOCOL_STATUS;
            optionTLV.length = sizeof(CANFD_MCANProtocolStatus);
            optionTLV.value = (void*) &protoStatus;
    
            retVal =  CANFD_getOptions(canHandle, &optionTLV, &errCode);
            if (retVal < 0)
            {
                System_printf ("Error: CANFD get protocol status failed [Error code %d]\n", errCode);
            }
    
            System_printf("Debug: LEC                               : %d\n", protoStatus.lastErrCode);
            System_printf("Debug: Activity                          : %d\n", protoStatus.act);
            System_printf("Debug: Error Passive                     : %d\n", protoStatus.errPassive);
            System_printf("Debug: Warning Status                    : %d\n", protoStatus.warningStatus);
            System_printf("Debug: Bus Off Status                    : %d\n", protoStatus.busOffStatus);
            System_printf("Debug: Data Phase LEC                    : %d\n", protoStatus.dlec);
            System_printf("Debug: Rx ESI flag                       : %d\n", protoStatus.resi);
            System_printf("Debug: Rx BRS flag                       : %d\n", protoStatus.rbrs);
            System_printf("Debug: Rx CAN FD                         : %d\n", protoStatus.rfdf);
            System_printf("Debug: Protocol Exception Event          : %d\n", protoStatus.pxe);
            System_printf("Debug: TDC value                         : %d\n", protoStatus.tdcv);
            System_printf("\n\n");
        }
    
        return 0;
    }
    
    /**
     *  @b Description
     *  @n
     *      System Initialization Task which initializes the various
     *      components in the system.
     *
     *  @retval
     *      Not Applicable.
     */
    static void Test_initTask(UArg arg0, UArg arg1)
    {
        int32_t         retVal = 0;
    
        /* Initialize the test logger framework: */
        MCPI_Initialize ();
    
        /* Initialize the platform */
        retVal = PlatformInit();
        if (retVal < 0)
        {
            MCPI_setFeatureTestResult("Platform initialization failed", MCPI_TestResult_FAIL);
            MCPI_setTestResult ();
            BIOS_exit(0);
        }
    
        while (1)
        {
            System_printf ("*******************************************************\n");
            System_printf ("CANFD Unit Test Menu                        \n");
            System_printf ("Please select the type of test to execute:  \n");
            System_printf ("1. MCAN Internal loopback test              \n");
            System_printf ("2. MCAN External loopback test              \n");
            System_printf ("3. MCAN Parity test                         \n");
            System_printf ("4. MCAN External Tx/Rx test                 \n");
            System_printf ("5. MCAN EVM-EVM test                        \n");
            System_printf ("6. MCAN Tx Cancel test                      \n");
            System_printf ("7. MCAN Power down test                     \n");
            System_printf ("*******************************************************\n");
            System_printf ("> Enter your selection: ");
    
            while (testSelection == 0);
    
            /* Validate the selection: */
            if ((testSelection >= MCAN_APP_TEST_INTERNAL_LOOPBACK) && (testSelection <= MCAN_APP_TEST_POWERDOWN))
                break;
        }
    
        if (testSelection == MCAN_APP_TEST_INTERNAL_LOOPBACK)
        {
            System_printf("Debug: Internal loopback testing\n");
            retVal = mcanLoopbackTest();
            if (retVal == -1)
                MCPI_setFeatureTestResult("Internal loopback testing", MCPI_TestResult_FAIL);
            else
                MCPI_setFeatureTestResult("Internal loopback testing", MCPI_TestResult_PASS);
        }
        else if (testSelection == MCAN_APP_TEST_EXTERNAL_LOOPBACK)
        {
            System_printf("Debug: External loopback testing\n");
            retVal = mcanLoopbackTest();
            if (retVal == -1)
                MCPI_setFeatureTestResult("External loopback testing", MCPI_TestResult_FAIL);
            else
                MCPI_setFeatureTestResult("External loopback testing", MCPI_TestResult_PASS);
        }
        else if (testSelection == MCAN_APP_TEST_TX_CANCEL)
        {
            System_printf("Debug: Tx Cancel testing\n");
            retVal = mcanLoopbackTest();
            if (retVal == -1)
                MCPI_setFeatureTestResult("Tx Cancel testing", MCPI_TestResult_FAIL);
            else
                MCPI_setFeatureTestResult("Tx Cancel testing", MCPI_TestResult_PASS);
        }
        else if (testSelection == MCAN_APP_TEST_EXTERNAL_DATA)
        {
            System_printf("Debug: External transmit testing\n");
            retVal = mcanTransmitTest();
            if (retVal == -1)
                MCPI_setFeatureTestResult("External transmit testing", MCPI_TestResult_FAIL);
            else
                MCPI_setFeatureTestResult("External transmit testing", MCPI_TestResult_PASS);
        }
        else if (testSelection == MCAN_APP_TEST_EVM_EVM)
        {
            System_printf("Debug: EVM-EVM testing\n");
            retVal = mcanEVM_EVMTest();
            if (retVal == -1)
                MCPI_setFeatureTestResult("EVM to EVM testing", MCPI_TestResult_FAIL);
            else
                MCPI_setFeatureTestResult("EVM to EVM testing", MCPI_TestResult_PASS);
        }
        else if (testSelection == MCAN_APP_TEST_POWERDOWN)
        {
            System_printf("Debug: Power Down testing\n");
            retVal = mcanPowerDownTest();
            if (retVal == -1)
                MCPI_setFeatureTestResult("Power Down testing", MCPI_TestResult_FAIL);
            else
                MCPI_setFeatureTestResult("Power Down testing", MCPI_TestResult_PASS);
        }
        if (retVal < 0)
        {
            System_printf("Debug:CANFD testing failed\n");
        }
    
        MCPI_setTestResult ();
    
        /* Exit BIOS */
        BIOS_exit(0);
    
        return;
    }
    
    /**
     *  @b Description
     *  @n
     *      This is the entry point into the unit test code
     *
     *  @retval
     *      Not Applicable.
     */
    int32_t main (void)
    {
    	Task_Params     taskParams;
        SOC_Handle      socHandle;
        SOC_Cfg         socCfg;
        int32_t         errCode;
    
        /* Initialize the ESM: Dont clear errors as TI RTOS does it */
        ESM_init(0U);
    
        /* Initialize the SOC confiugration: */
        memset ((void *)&socCfg, 0, sizeof(SOC_Cfg));
    
        /* Populate the SOC configuration: */
        socCfg.clockCfg = SOC_SysClock_INIT;
    
        /* Initialize the SOC Module: This is done as soon as the application is started
         * to ensure that the MPU is correctly configured. */
        socHandle = SOC_init (&socCfg, &errCode);
        if (socHandle == NULL)
        {
            System_printf ("Error: SOC Module Initialization failed [Error code %d]\n", errCode);
            return -1;
        }
    
        /* Configure the divide value for MCAN source clock */
        SOC_setPeripheralClock(socHandle, SOC_MODULE_MCAN, SOC_CLKSOURCE_VCLK, 4U, &errCode);
    
        /* Initialize the Task Parameters. */
        Task_Params_init(&taskParams);
        taskParams.stackSize = 1024;
        // taskParams.stackSize = 6*1024;
        Task_create(Test_initTask, &taskParams, NULL);
    
        /* Start BIOS */
    	BIOS_start();
        return 0;
    }
    
    
    

  • Thanks Raghu

    The resolved the issue.