IWR1642BOOST: CAN transmit not working

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 

4 Replies

  • Hi Tim,

    Did you try running the same test with the unit test provided with the CAN driver? I would recommend you to first get the TX test working with the unit test to have a working baseline and test setup and then run your own code.

    Regards
    -Nitin
  • In reply to Nitin Sakhuja:

    Hi Nitin,

    I have now run the CAN driver unit test thanks to your help on my other post. 

    I have run the tests with a 120 ohm resistance between the can_l and can_h ports, probing both ports and also have probed the pin 1 of the CAN transceiver U3 but am not seeing any reading on the scope. 

    Running the DCAN Internal loopback test I get this on the console but only see flat voltage level on the scope.

    [Cortex_R4_0] *******************************************************
    CAN Unit Test Menu                          
    Please select the type of test to execute:  
    1. DCAN Internal loopback test              
    2. DCAN External loopback test              
    3. DCAN Parity test                         
    4. DCAN Tx/Rx test                          
    *******************************************************
    > Enter your selection: Debug: Internal loopback testing
    Debug: Number of iterations              : 100
    Debug: Number of messages transmitted    : 100
    Debug: Number of messages received       : 100
    Debug: Number of messages lost           : 0
    Debug: Number of data mismatch           : 0
    Debug: Error Status Interrupt            : 0
    
    
    Debug: Message object number             : 1
    Debug: Direction                         : Transmit
    Debug: Number of interrupts received     : 100
    Debug: Number of messages processed      : 100
    
    
    Debug: Message object number             : 2
    Debug: Direction                         : Receive
    Debug: Number of interrupts received     : 100
    Debug: Number of messages processed      : 100
    Debug: Receive & Transmit Measurements
    Debug: Rx Min:470 Max: 503 Average:476 ticks
    Debug: Tx Min:459 Max: 1340 Average:474 ticks
    
    
    Debug: Internal loopback testing for 100 iterations Passed
    Feature: Internal loopback testing: Passed
    

    Runing the DCAN External loopback test  I get this on the console and again the same reading on the scope.

    [Cortex_R4_0] *******************************************************
    CAN Unit Test Menu                          
    Please select the type of test to execute:  
    1. DCAN Internal loopback test              
    2. DCAN External loopback test              
    3. DCAN Parity test                         
    4. DCAN Tx/Rx test                          
    *******************************************************
    > Enter your selection: Debug: External loopback testing
    Debug: Number of iterations              : 100
    Debug: Number of messages transmitted    : 100
    Debug: Number of messages received       : 100
    Debug: Number of messages lost           : 0
    Debug: Number of data mismatch           : 0
    Debug: Error Status Interrupt            : 0
    
    
    Debug: Message object number             : 1
    Debug: Direction                         : Transmit
    Debug: Number of interrupts received     : 100
    Debug: Number of messages processed      : 100
    
    
    Debug: Message object number             : 2
    Debug: Direction                         : Receive
    Debug: Number of interrupts received     : 100
    Debug: Number of messages processed      : 100
    Debug: Receive & Transmit Measurements
    Debug: Rx Min:463 Max: 1344 Average:478 ticks
    Debug: Tx Min:459 Max: 476 Average:466 ticks
    
    
    Debug: External loopback testing for 100 iterations Passed
    Feature: External loopback testing: Passed

    Running the DCAN Parity test  I get this on the console and the same reading again on the scope.

    [Cortex_R4_0] *******************************************************
    CAN Unit Test Menu                          
    Please select the type of test to execute:  
    1. DCAN Internal loopback test              
    2. DCAN External loopback test              
    3. DCAN Parity test                         
    4. DCAN Tx/Rx test                          
    *******************************************************
    > Enter your selection: Debug: parity testing
    Error: ECC error status check failed. Single bit error 0 Double bit error 1 Message Number 64
    Feature: Parity testing: Failed
    Debug:CAN testing failed

    Finally running DCAN Tx/Rx test I see this in the console and still the same on the scope.

    [Cortex_R4_0] *******************************************************
    CAN Unit Test Menu                          
    Please select the type of test to execute:  
    1. DCAN Internal loopback test              
    2. DCAN External loopback test              
    3. DCAN Parity test                         
    4. DCAN Tx/Rx test                          
    *******************************************************
    > Enter your selection: Debug: External transmit testing
    Debug: External transmit testing Passed
    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 object number             : 1
    Debug: Direction                         : Transmit
    Debug: Number of interrupts received     : 0
    Debug: Number of messages processed      : 1
    
    
    Debug: Message object number             : 2
    Debug: Direction                         : Receive
    Debug: Number of interrupts received     : 0
    Debug: Number of messages processed      : 0
    
    
    Debug: Receive passive error             : 0
    Debug: Transmit Error Counter            : 136
    Debug: Receive Error Counter             : 0

    Does this provide insight as to what the problem might be? 

    Thanks, 

    Tim 

  • In reply to Tim Dunham:

    Hi Tim,

    Going through the description in your previous post, it is not clear if you've followed the required ECOs as mentioned in Appendix A.4 of the following app note:

    CAN Node on AWR1642

    Could you please confirm if you've mounted 0 ohm resistor on R11 and R12 and removed R6 and R4 as required?

    Regards

    -Nitin

     

  • In reply to Nitin Sakhuja:

    Hi Nitin,

    I am using the IWR1642BOOST EVM so I followed the instructions in section 2.3.3 of that user guide http://www.ti.com/lit/ug/swru521b/swru521b.pdf and mounted 0 ohms on R11 and R12 and removed R4, R6, R28 and R63.

    Additionally, I have now tried runng the CANFD driver unit test and found that works and shows the expected output on the scope so I have tried changeing my program to use CANFD rather than CAN. This still is not working but it does give an error message. It is failing to transmit with error code -3502, which  I think is EINUSE meaning the last message is still being sent? I am only calling  CANFD_transmitData() once per frame so there should be long enough between sending the messages?

    Thanks,

    Tim