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.

Project DCAN_RX not working

Hardware: TMS570LC43x / RM57Lx 337 7WT Launchpad XL2

Code: code example DCAN_RX

int main(void)
{
/* USER CODE BEGIN (3) */
canInit(); // Initialize the CAN Module
sciInit(); // Initialize the SCI (UART) Module

while(!canIsRxMessageArrived(canREG1, canMESSAGE_BOX1)); // Wait till a message is received on CAN1, Msg Box1
canGetData(canREG1, canMESSAGE_BOX1, rx_data); // Store the received data in rx_data

error = checkPackets(&tx_data[0], &rx_data[0], D_SIZE); // Check if the message received is same as expected
sciSend(sciREG1, D_SIZE, rx_data); // Send the received message through UART

while(1); // Infinite Loop
/* USER CODE END */
}

uint32 canIsRxMessageArrived(canBASE_t *node, uint32 messageBox)
{
uint32 flag;
uint32 regIndex = (messageBox - 1U) >> 5U;
uint32 bitIndex = 1U << ((messageBox - 1U) & 0x1FU);

/* USER CODE BEGIN (16) */
/* USER CODE END */

/** - Read Tx request register */
flag = node->NWDATx[regIndex] & bitIndex;

/* USER CODE BEGIN (17) */
/* USER CODE END */

return flag;
}

Issues:

The code run while loop at canIsRxMessageArrived() and stuck here.

It means that DCAN has never received data.

My question is where the application note for this codes example? 

Are there any wired in at RX pin of DCAN1 port?

Thanks,

F

  • Hi Lee,

    The TMS570LC43x launchpad doesn't include CAN transceiver, so the launchpad can not be connected to CAN network directly. 

    There are many CAN transceiver adaptor in the market:

    https://www.robotshop.com/en/waveshare-can-board-sn65hvd230.html?gclid=Cj0KCQjwwNWKBhDAARIsAJ8Hkhfo2ZQJREVt58U56YbK3OqTJ_RLHIKytmzgPy4KEQQ0Iknz2rsaFvEaArnCEALw_wcB

    You can plug this kind of small adaptor onto the launchpad.

  • When TMS570 CAN transmits data, is the data appeared on the CAN bus? The waveform on the CAN_H and CAN_L look like:

    If you see the correct transmitted message waveform on the CAN bus, the CAN receiver may not be configured correctly to get the data. 

  • Hi, QJ Wang,

    Thank you for quick response.

    I use another TMS570LC43x launchpad with transceivers connected.

    DCAN 3 as transmitter to transmit data and DCAN 4 as receiver to receive data, but receiver doesn't get the data.

    DCAN 3 transmits data to the registers DCAN IF1DATA and DCAN IF1DATB. How to make sure that data are go to pin Tx?

    The codes: 

    uint32 canTransmit(canBASE_t *node, uint32 messageBox, const uint8 * data)

    {

          node->IF1DATx[i] = *data;

    }

    DCAN 4 receives data from 

    uint32 canIsRxMessageArrived(canBASE_t *node, uint32 messageBox)

    {

         flag = node->NWDATx[regIndex] & bitIndex;

    }

    flag has never be set, so codes are loop here infinitely in while loop in main().

    uint32 canGetData(canBASE_t *node, uint32 messageBox, uint8 * const data)

    {

         *pData = node->IF2DATx[s_canByteOrder[i]];

    }

    int main(void)
    {
          /* USER CODE BEGIN (3) */
          canInit(canREG3); // Initialize the CAN Module Channel3
          canInit(canREG4); // Initialize the CAN Module Channel4

          canTransmit(canREG3, canMESSAGE_BOX1, tx_data); // Transmit data through Msg Box1 of CAN3

          while(!canIsRxMessageArrived(canREG4, canMESSAGE_BOX1)); // Wait till a message is received on CAN4, Msg Box1
          canGetData(canREG4, canMESSAGE_BOX1, rx_data); // Store the received data in rx_data

           error = checkPackets(&tx_data[0], &rx_data[0], D_SIZE); // Check if the message received is same as expected


            while(1); // Infinite Loop
    /* USER CODE END */
    }

    Thanks,

    F

  • Hi Lee,

    Please read my comment in another thread you open days ago.