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.

Transmit fault of TMS570ls1227 DCAN

Other Parts Discussed in Thread: TMS570LS1227

My dear friends,I have some questions about the sending function of TMS570ls1227 DCAN

 TMS570LS1227 Using the test program from TI's official website ,But the sending function of the program has not been successful.

call the function of “canTransmit(canBASE_t *node, uint32 messageBox, const uint8 * data)” the success Flag is always 0.

if ((node->TXRQx[regIndex] & bitIndex) != 0U)
{
success = 0U;
}

May I ask what is the reason? My project files are stored in the annex.

2772.project.zip

  • Hello, 

      Do you have a CAN netowrk setup? Do you have other nodes on the network to receive the messages from the MCU?

      Reset the device first and place a breakpoint at line:

            if ((node->TXRQx[regIndex] & bitIndex) != 0U)

      You should see that the first time the success = 0U is not entered but rather the 'else' clause is taken. Once the CAN message is sent, other nodes on the network are supposed to reply acknowledge if the message is intended for them. If message is not acknowledged then the CAN transmitter will keep repeating sending the message.  The next time a RTI interrupt is generated the canTransmit() first check if the last transmit was successful. If the last message was not successful then it will not initiate another message again. 

      So the first thing to check is if you have other nodes on the network receiving the message and acknowledging the reception of the message.

  • Thank you for answering my question.

    As you say reset the device and place a breakpoint at line:

     if ((node->TXRQx[regIndex] & bitIndex) != 0U) .

    The first time the success = 0U is not entered but rather the 'else' clause is taken,And then the success Flag is always 0.Can not generated "canMessageNotification" interrupt .

    But i have not other nodes on the network receiving the message,and just the  DCAN1 module is enabled..

    MESSAGE_BOX1-MESSAGE_BOX4 as transmition messagebox,MESSAGE_BOX5-MESSAGE_BOX8 as reception  messagebox.

    The main function procedure is as follows:

    void main(void)
    {
    /* USER CODE BEGIN (3) */
    unsigned char i;
    canInit();
    rtiInit();
    rtiStartCounter(rtiCOUNTER_BLOCK0);
    rtiEnableNotification(rtiNOTIFICATION_COMPARE0);
    Tx_Data_CAN_1[0] = 0x0081;
    Tx_Data_CAN_2[0] = 0x0091;
    Tx_Data_CAN_3[0] = 0x00A1;
    Tx_Data_CAN_4[0] = 0x00B1;
    for(i=1;i<TG_LENGTH;i++)
    {
    Tx_Data_CAN_1[i] = Tx_Data_CAN_1[i-1]+1;
    Tx_Data_CAN_2[i] = Tx_Data_CAN_2[i-1]+1;
    Tx_Data_CAN_3[i] = Tx_Data_CAN_3[i-1]+1;
    Tx_Data_CAN_4[i] = Tx_Data_CAN_4[i-1]+1;
    }
    _enable_IRQ();
    while(1)
    {
    ;// canTransmit(canREG1,canMESSAGE_BOX1,Tx_Data_CAN);
    }
    /* USER CODE END */
    }

    /* USER CODE BEGIN (4) */
    void rtiNotification(uint32 notification)
    {
    /* enter user code between the USER CODE BEGIN and USER CODE END. */
    /* USER CODE BEGIN (9) */
    canTransmit(canREG1,canMESSAGE_BOX1,Tx_Data_CAN_1);
    canTransmit(canREG1,canMESSAGE_BOX2,Tx_Data_CAN_2);
    canTransmit(canREG1,canMESSAGE_BOX3,Tx_Data_CAN_3);
    canTransmit(canREG1,canMESSAGE_BOX4,Tx_Data_CAN_4);
    /* USER CODE END */
    }

    void canMessageNotification(canBASE_t *node, uint32 messageBox)
    {
    /* enter user code between the USER CODE BEGIN and USER CODE END. */
    /* USER CODE BEGIN (15) */
    switch(messageBox)
    {
    case canMESSAGE_BOX5:
    canGetData(canREG1,canMESSAGE_BOX5,Rx_Data_CAN_1);

    break;
    case canMESSAGE_BOX6:
    canGetData(canREG1,canMESSAGE_BOX6,Rx_Data_CAN_2);

    break;
    case canMESSAGE_BOX7:
    canGetData(canREG1,canMESSAGE_BOX7,Rx_Data_CAN_3);

    break;
    case canMESSAGE_BOX8:
    canGetData(canREG1,canMESSAGE_BOX8,Rx_Data_CAN_4);

    break;
    default :
    break;
    }
    /* USER CODE END */
    }
    /* USER CODE END */

    Attachment content is the configuration file of DCAN1 module.

    regards

  • Do you have the receiver mailbox configured to receive the message ID transmitted from the transmitter?
    Do you have transceiver on your board?
  • Hello,

    The receiver mailboxs have been configured.

    canREG1->IF1MSK = 0xC0000000U | (uint32)((uint32)((uint32)0x000007FFU & (uint32)0x000007FFU) << (uint32)18U);
    canREG1->IF1ARB = (uint32)0x80000000U | (uint32)0x00000000U | (uint32)0x20000000U | (uint32)((uint32)((uint32)0x01U & (uint32)0x000007FFU) << (uint32)18U);
    canREG1->IF1MCTL = 0x00001080U | (uint32)0x00000000U | (uint32)0x00000000U | (uint32)8U;
    canREG1->IF1CMD = (uint8) 0xF8U;
    canREG1->IF1NO = 1U;

    /** - Initialize message 2
    * - Wait until IF2 is ready for use
    * - Set message mask
    * - Set message control word
    * - Set message arbitration
    * - Set IF2 control byte
    * - Set IF2 message number
    */
    /*SAFETYMCUSW 28 D MR:NA <APPROVED> "Potentially infinite loop found - Hardware Status check for execution sequence" */
    while ((canREG1->IF2STAT & 0x80U) ==0x80U)
    {
    } /* Wait */

    canREG1->IF2MSK = 0xC0000000U | (uint32)((uint32)((uint32)0x000007FFU & (uint32)0x000007FFU) << (uint32)18U);
    canREG1->IF2ARB = (uint32)0x80000000U | (uint32)0x00000000U | (uint32)0x20000000U | (uint32)((uint32)((uint32)0x02U & (uint32)0x000007FFU) << (uint32)18U);
    canREG1->IF2MCTL = 0x00001080U | (uint32)0x00000000U | (uint32)0x00000000U | (uint32)8U;
    canREG1->IF2CMD = (uint8) 0xF8U;
    canREG1->IF2NO = 2U;

    /** - Initialize message 3
    * - Wait until IF1 is ready for use
    * - Set message mask
    * - Set message control word
    * - Set message arbitration
    * - Set IF1 control byte
    * - Set IF1 message number
    */
    /*SAFETYMCUSW 28 D MR:NA <APPROVED> "Potentially infinite loop found - Hardware Status check for execution sequence" */
    while ((canREG1->IF1STAT & 0x80U) ==0x80U)
    {
    } /* Wait */

    canREG1->IF1MSK = 0xC0000000U | (uint32)((uint32)((uint32)0x000007FFU & (uint32)0x000007FFU) << (uint32)18U);
    canREG1->IF1ARB = (uint32)0x80000000U | (uint32)0x00000000U | (uint32)0x20000000U | (uint32)((uint32)((uint32)0x03U & (uint32)0x000007FFU) << (uint32)18U);
    canREG1->IF1MCTL = 0x00001080U | (uint32)0x00000000U | (uint32)0x00000000U | (uint32)8U;
    canREG1->IF1CMD = (uint8) 0xF8U;
    canREG1->IF1NO = 3U;

    /** - Initialize message 4
    * - Wait until IF2 is ready for use
    * - Set message mask
    * - Set message control word
    * - Set message arbitration
    * - Set IF2 control byte
    * - Set IF2 message number
    */
    /*SAFETYMCUSW 28 D MR:NA <APPROVED> "Potentially infinite loop found - Hardware Status check for execution sequence" */
    while ((canREG1->IF2STAT & 0x80U) ==0x80U)
    {
    } /* Wait */

    canREG1->IF2MSK = 0xC0000000U | (uint32)((uint32)((uint32)0x000007FFU & (uint32)0x000007FFU) << (uint32)18U);
    canREG1->IF2ARB = (uint32)0x80000000U | (uint32)0x00000000U | (uint32)0x20000000U | (uint32)((uint32)((uint32)0x04U & (uint32)0x000007FFU) << (uint32)18U);
    canREG1->IF2MCTL = 0x00001080U | (uint32)0x00000000U | (uint32)0x00000000U | (uint32)8U;
    canREG1->IF2CMD = (uint8) 0xF8U;
    canREG1->IF2NO = 4U;

    /** - Initialize message 5
    * - Wait until IF1 is ready for use
    * - Set message mask
    * - Set message control word
    * - Set message arbitration
    * - Set IF1 control byte
    * - Set IF1 message number
    */
    /*SAFETYMCUSW 28 D MR:NA <APPROVED> "Potentially infinite loop found - Hardware Status check for execution sequence" */
    while ((canREG1->IF1STAT & 0x80U) ==0x80U)
    {
    } /* Wait */

    canREG1->IF1MSK = 0xC0000000U | (uint32)((uint32)((uint32)0x000007FFU & (uint32)0x000007FFU) << (uint32)18U);
    canREG1->IF1ARB = (uint32)0x80000000U | (uint32)0x00000000U | (uint32)0x00000000U | (uint32)((uint32)((uint32)0x05U & (uint32)0x000007FFU) << (uint32)18U);
    canREG1->IF1MCTL = 0x00001080U | (uint32)0x00000400U | (uint32)0x00000000U | (uint32)8U;
    canREG1->IF1CMD = (uint8) 0xF8U;
    canREG1->IF1NO = 5U;

    /** - Initialize message 6
    * - Wait until IF2 is ready for use
    * - Set message mask
    * - Set message control word
    * - Set message arbitration
    * - Set IF2 control byte
    * - Set IF2 message number
    */
    /*SAFETYMCUSW 28 D MR:NA <APPROVED> "Potentially infinite loop found - Hardware Status check for execution sequence" */
    while ((canREG1->IF2STAT & 0x80U) ==0x80U)
    {
    } /* Wait */

    canREG1->IF2MSK = 0xC0000000U | (uint32)((uint32)((uint32)0x000007FFU & (uint32)0x000007FFU) << (uint32)18U);
    canREG1->IF2ARB = (uint32)0x80000000U | (uint32)0x00000000U | (uint32)0x00000000U | (uint32)((uint32)((uint32)0x06U & (uint32)0x000007FFU) << (uint32)18U);
    canREG1->IF2MCTL = 0x00001080U | (uint32)0x00000400U | (uint32)0x00000000U | (uint32)8U;
    canREG1->IF2CMD = (uint8) 0xF8U;
    canREG1->IF2NO = 6U;

    /** - Initialize message 7
    * - Wait until IF1 is ready for use
    * - Set message mask
    * - Set message control word
    * - Set message arbitration
    * - Set IF1 control byte
    * - Set IF1 message number
    */
    /*SAFETYMCUSW 28 D MR:NA <APPROVED> "Potentially infinite loop found - Hardware Status check for execution sequence" */
    while ((canREG1->IF1STAT & 0x80U) ==0x80U)
    {
    } /* Wait */

    canREG1->IF1MSK = 0xC0000000U | (uint32)((uint32)((uint32)0x000007FFU & (uint32)0x000007FFU) << (uint32)18U);
    canREG1->IF1ARB = (uint32)0x80000000U | (uint32)0x00000000U | (uint32)0x00000000U | (uint32)((uint32)((uint32)0x07U & (uint32)0x000007FFU) << (uint32)18U);
    canREG1->IF1MCTL = 0x00001080U | (uint32)0x00000400U | (uint32)0x00000000U | (uint32)8U;
    canREG1->IF1CMD = (uint8) 0xF8U;
    canREG1->IF1NO = 7U;

    /** - Initialize message 8
    * - Wait until IF2 is ready for use
    * - Set message mask
    * - Set message control word
    * - Set message arbitration
    * - Set IF2 control byte
    * - Set IF2 message number
    */
    /*SAFETYMCUSW 28 D MR:NA <APPROVED> "Potentially infinite loop found - Hardware Status check for execution sequence" */
    while ((canREG1->IF2STAT & 0x80U) ==0x80U)
    {
    } /* Wait */

    canREG1->IF2MSK = 0xC0000000U | (uint32)((uint32)((uint32)0x000007FFU & (uint32)0x000007FFU) << (uint32)18U);
    canREG1->IF2ARB = (uint32)0x80000000U | (uint32)0x00000000U | (uint32)0x00000000U | (uint32)((uint32)((uint32)0x08U & (uint32)0x000007FFU) << (uint32)18U);
    canREG1->IF2MCTL = 0x00001080U | (uint32)0x00000400U | (uint32)0x00000000U | (uint32)8U;
    canREG1->IF2CMD = (uint8) 0xF8U;
    canREG1->IF2NO = 8U;

    Attachment content is the configuration file of DCAN1 module.

    8233.can .c

    regards

  • I will suggest that you map the receiver mailboxes to DCAN2 module on the HDK board. This way you have two nodes on the bus where the DCAN2 can receive the messages transmitted by DCAN1. You can't just have one node on the bus. When there is only one node the bus, the message transmitted out will get no acknowledgement and it will detect as error and repeat the message continuously.