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.

  • TI Thinks Resolved

IWR1642BOOST: CAN transmit not working

Prodigy 170 points

Replies: 13

Views: 709

Part Number: IWR1642BOOST

  •  mmWave SDK 01.02.00.05

  • IWR1642BOOST

  • Silicon revision ES1.0

  • Code Composer Studio Version: 8.1.0.00011 

Hello,


I am attempting to add sending data over CAN to a program for the IWR1642BOOST.

I have added and removed resistors are instructed in the user guide.

My code to implement the CAN is largely lifted from the various example programs so DCANAppCalcBitTimeParams() is just taken from the can driver unit test program.

void Can_Initialize(void)
{
    CAN_MsgObjHandle rxMsgObjHandle;
    int32_t retVal = 0;
    int32_t errCode = 0;
    CAN_DCANMsgObjectStats msgObjStats;
    CAN_OptionTLV optionTLV;
    CAN_DCANErrorCounter errCounter;

    /* Setup the PINMUX to bring out the XWR16xx CAN pins */
    Pinmux_Set_OverrideCtrl(SOC_XWR16XX_PINC13_PADAG,
                            PINMUX_OUTEN_RETAIN_HW_CTRL,
                            PINMUX_INPEN_RETAIN_HW_CTRL);
    Pinmux_Set_FuncSel(SOC_XWR16XX_PINC13_PADAG,
                       SOC_XWR16XX_PINC13_PADAG_CAN_TX);

    Pinmux_Set_OverrideCtrl(SOC_XWR16XX_PINE13_PADAF,
                            PINMUX_OUTEN_RETAIN_HW_CTRL,
                            PINMUX_INPEN_RETAIN_HW_CTRL);
    Pinmux_Set_FuncSel(SOC_XWR16XX_PINE13_PADAF,
                       SOC_XWR16XX_PINE13_PADAF_CAN_RX);

    /* Configure the divide value for DCAN source clock */
    SOC_setPeripheralClock(gMmwMssMCB.socHandle, SOC_MODULE_DCAN,
                           SOC_CLKSOURCE_VCLK, 9U, &errCode);

    /* Initialize peripheral memory */
    SOC_initPeripheralRam(gMmwMssMCB.socHandle, SOC_MODULE_DCAN, &errCode);

    /* Initialize the DCAN parameters that need to be specified by the application */
    DCANAppInitParams(&appDcanCfgParams, &appDcanTxCfgParams, &appDcanRxCfgParams);
    gMmwMssMCB.canHandle = CAN_init(&appDcanCfgParams, &errCode);
    if (gMmwMssMCB.canHandle == NULL)
    {
        System_printf(
                "Error: CAN Module Initialization failed [Error code %d]\n",
                errCode);
        //return -1;
    }

    retVal = DCANAppCalcBitTimeParams(20000000U / 1000000,
                                      1000000U / 1000,
                                      1000000U,
                                      700U,
                                                &appDcanBitTimeParams);

    /* Configure the CAN driver */
    retVal = CAN_configBitTime(gMmwMssMCB.canHandle, &appDcanBitTimeParams, &errCode);
    if (retVal < 0)
    {
        System_printf(
                "Error: CAN Module configure bit time failed [Error code %d]\n",
                errCode);
        //return -1;
    }
    /* Setup the transmit message object */
    gMmwMssMCB.txMsgObjHandle = CAN_createMsgObject(gMmwMssMCB.canHandle, 1,
                                         &appDcanTxCfgParams, &errCode);
    if (gMmwMssMCB.txMsgObjHandle == NULL)
    {
        System_printf(
                "Error: CAN create Tx message object failed [Error code %d]\n",
                errCode);
        //return -1;
    }

    /* Setup the receive message object */
    rxMsgObjHandle = CAN_createMsgObject(gMmwMssMCB.canHandle, 2,
                                         &appDcanRxCfgParams, &errCode);
    if (rxMsgObjHandle == NULL)
    {
        System_printf(
                "Error: CAN create Rx message object failed [Error code %d]\n",
                errCode);
        //return -1;
    }
}

and it is using these parameters

static void DCANAppInitParams(CAN_DCANCfgParams* dcanCfgParams,
                              CAN_DCANMsgObjCfgParams* dcanTxCfgParams,
                              CAN_DCANMsgObjCfgParams* dcanRxCfgParams)
{
    /*Intialize DCAN Config Params*/
    dcanCfgParams->parityEnable = 0;
    dcanCfgParams->intrLine0Enable = 1;
    dcanCfgParams->intrLine1Enable = 1;
    dcanCfgParams->testModeEnable = 0;
    dcanCfgParams->eccModeEnable = 0;
    dcanCfgParams->stsChangeIntrEnable = 0;
    dcanCfgParams->autoRetransmitDisable = 1;
    dcanCfgParams->autoBusOnEnable = 0;
    dcanCfgParams->errIntrEnable = 1;
    dcanCfgParams->autoBusOnTimerVal = 0;
    dcanCfgParams->if1DmaEnable = 0;
    dcanCfgParams->if2DmaEnable = 0;
    dcanCfgParams->if3DmaEnable = 0;
    dcanCfgParams->ramAccessEnable = 0;
    dcanCfgParams->appCallBack = DCANAppErrStatusCallback;
    /*Intialize DCAN tx Config Params*/
    dcanTxCfgParams->xIdFlagMask = 0x1;
    dcanTxCfgParams->dirMask = 0x1;
    dcanTxCfgParams->msgIdentifierMask = 0x1FFFFFFF;
    dcanTxCfgParams->msgValid = 1;
    dcanTxCfgParams->xIdFlag = CAN_DCANXidType_11_BIT;
    dcanTxCfgParams->direction = CAN_Direction_TX;
    dcanTxCfgParams->msgIdentifier = 0xC1; //this is what needs to be determined
    dcanTxCfgParams->uMaskUsed = 1;
    dcanTxCfgParams->intEnable = 1;
    dcanTxCfgParams->remoteEnable = 0;
    dcanTxCfgParams->fifoEOBFlag = 1;
    dcanTxCfgParams->appCallBack = DCANAppCallback;
    /*Intialize DCAN Rx Config Params*/
    dcanRxCfgParams->xIdFlagMask = 0x1;
    dcanRxCfgParams->msgIdentifierMask = 0x1FFFFFFF;
    dcanRxCfgParams->dirMask = 0x1;
    dcanRxCfgParams->msgValid = 1;
    dcanRxCfgParams->xIdFlag = CAN_DCANXidType_11_BIT;
    dcanRxCfgParams->direction = CAN_Direction_RX;
    dcanRxCfgParams->msgIdentifier = 0xC1;
    dcanRxCfgParams->uMaskUsed = 1;
    dcanRxCfgParams->intEnable = 1;
    dcanRxCfgParams->remoteEnable = 0;
    dcanRxCfgParams->fifoEOBFlag = 1;
    dcanRxCfgParams->appCallBack = DCANAppCallback;

}

and the transmit is called in the mailbox task after transmiting data over UART, like so, where gMmwMssMCB.foldbackOverCan is of type CAN_DCANData

                    //transmit over can
                    retVal = CAN_transmitData(( CAN_MsgObjHandle*)gMmwMssMCB.txMsgObjHandle, &gMmwMssMCB.foldbackOverCan, &errCode);



                    if (retVal < 0)
                    {
                        /* Error: Unable to send the message. Setup the error code and return values */
                        System_printf(
                                "Error: failed to transmit foldback over CAN [Error code %d]\n",
                                errCode);
                    }

The program does not give any errors but if I probe the can_l and can_h ports they both just give A 2.5v level when my program is running.

What might be causing the CAN transmit to not work? Any suggestions on how to debug this?

Thanks,

Tim 

  • In reply to Nitin Sakhuja:

    Hi Tim,

    We have not heard back from you on this thread. Could you please reply whether you still need support on this topic?

    Thanks
    -Nitin
  • In reply to Nitin Sakhuja:

    Hi Nitin,

    I have probed and seen the CAN Tx/Rx signals on the J5/J6 connectors.
    Unfortunately there has been a separate issue with the EVM causing it to be necessary to get a new one.

    Once I have got this new EVM I plan on using wires to connect pin 13 of connector J6 to pin 12 on connector J5 and to connect pin 6 on connector J5 to pin 14 on connector J5. I think that, along with adding / removing the appropriate 0 ohm resistors, this will route the CAN tx/ Rx signals to the CAN transceiver on the EVM.

    Should this work?

    Thanks,

    Tim
  • In reply to Tim Dunham:

    Hi Tim,

    I would suggest getting an MMWAVE-DEVPACK to run the test. I'll close this thread for now but please feel free to create a new thread if you face issues with the new EVM (you can refer to this thread when creating the new one).

    Regards

    -Nitin

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.