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.

TMS570LS3137: CAN Communication

Part Number: TMS570LS3137
Other Parts Discussed in Thread: HALCOGEN

Hi,

I am trying to send data between two TMS570LS3137 processors through CAN communication. But retransmission of the same data is happening. refer the data enclosed below:

From board 1:

canTransmit(canREG1, canMESSAGE_BOX1, &Tx_data)

To Board 2:

 canGetData(canREG1, canMESSAGE_BOX1, &Rx_data).

As per the Technical reference manual

"According to the CAN Specification (ISO11898), the DCAN provides a mechanism to automatically

retransmit frames that have lost arbitration or have been disturbed by errors during transmission. The

frame transmission service will not be confirmed to the user before the transmission is successfully completed.By default, this automatic retransmission is enabled."

This is the code generated by Halcogen for the same

uint32 canTransmit(canBASE_t *node, uint32 messageBox, const uint8 * data)
{
    uint32 i;
    uint32 success  = 0U;
    uint32 regIndex = (messageBox - 1U) >> 5U;
    uint32 bitIndex = 1U << ((messageBox - 1U) & 0x1FU);

    /** - Check for pending message:
    *     - pending message, return 0
    *     - no pending message, start new transmission
    */
    if ((node->TXRQx[regIndex] & bitIndex) != 0U)
    {
        success = 0U;
    }

    else
    {
    /** - Wait until IF1 is ready for use */
    /*SAFETYMCUSW 28 D MR:NA <APPROVED> "Potentially infinite loop found - Hardware Status check for execution sequence" */
    while ((node->IF1STAT & 0x80U) ==0x80U)
    {
    } /* Wait */

    /** - Configure IF1 for
    *     - Message direction - Write
    *     - Data Update
    *     - Start Transmission
    */    
    node->IF1CMD = 0x87U;
    
    /** - Copy TX data into IF1 */
    for (i = 0U; i < 8U; i++)
    {
#if ((__little_endian__ == 1) || (__LITTLE_ENDIAN__ == 1))
        /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are only allowed in this driver" */
        node->IF1DATx[i] = *data;
        /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are only allowed in this driver" */
        /*SAFETYMCUSW 567 S MR:17.1,17.4 <APPROVED> "Pointer increment needed" */
        data++;
#else
        /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are only allowed in this driver" */
        node->IF1DATx[s_canByteOrder[i]] = *data;
        /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are only allowed in this driver" */
        /*SAFETYMCUSW 567 S MR:17.1,17.4 <APPROVED> "Pointer increment needed" */
        data++;
#endif
    }
    /** - Copy TX data into message box */
    /*SAFETYMCUSW 93 S MR: 6.1,6.2,10.1,10.2,10.3,10.4 <APPROVED> "LDRA Tool issue" */
    node->IF1NO = (uint8) messageBox;
    success = 1U;
    }
    return success;
}
How to disable this automatic retransmission is in the above function?

Thanks,

Jemin P James

  • Hello,

    Automatic transmission can be disabled by setting DAR bit in  CAN Control Register (DCAN CTL).

    You can set this bit from your application code. It is not necessary to disable it every time you transmit  CAN message. In general, HALCoGen puts
    /* USER CODE BEGIN (x) */
    /* USER CODE END */
    and you can write inside this comments. If you write outside this comments next time you generate the code your changes will be removed.

    Best regards,
    Miro