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.

Halcogen3.05 DCAN Problem

Other Parts Discussed in Thread: TMS570LS20216, HALCOGEN

Hello,

        I use TMS570LS20216 USB Kit and Halcogen3.05 test DCAN, there is my Halcogen configuration:

Here is my main code:

 canInit();

while(1)
 {
  if(canIsTxMessagePending(canREG1, 1) == 0)
  {
   for(i = 0; i < 8; i++)
   {
    g_ucCanTxData[i] += 1;
   }
   canTransmit(canREG1, 1, &g_ucCanTxData[0]);
  }
  
  for(i = 0; i < delay; i++)
   ;
  
  if(canIsRxMessageArrived(canREG1, 2) != 0)
  {
   canGetData(canREG1, 2, &g_ucCanRxData[0]);
  } 
  
  for(i = 0; i < delay; i++)
   ; 
 }

 

 But when i use  a CAN device to watch it's transmit data,  the data ID is 2 and it is not a data frame but remorte frame.Also, it can't receive any data.

I don't kow the reason, am i use the function(canTransmit and canGetData) or configuration incorrect ?

 

Please help.

Thank you.

Regards

Node

  • Hi Node,

    I see your configuration. So you want to do the loopback test on DCAN1, right? Then you need to configure DCAN1 working in loopback mode. Please using following code for configuration.


    /* Set DCAN1 to Loopback + Silent mode */
    canREG1->CTL |= 0x00000080;
    canREG1->TEST |= 0x00000018;

    I find you Message box 1 is used for sending and box 2 is used for receiving. The ID should be the same. Otherwise message box 2 will never receive message with ID equal to 1.

    Best Regards.

    Jay

  • Hi Jay:

    Thanks for your reply.But I use a external CAN device for receive and send message, not do the loopback test.

    I also use your suggestion do the loopback test, it doesn't work.When run canTransmit(), it always run here:

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

     

    Please help.

    Thank you.

    Regards

    Node

  • Hello:

    I ues the ccs debug the program and i find after canInit(), the value of the message 1 ram at 0x0024(offset from base address, Xtd, Dir, ID) and message 2 ram at 0x0048(offset from base address, Xtd, Dir, ID) are always the same value : 0x40000002.So, i initialization the DCAN 2 times like this:

    canInit();

    canInit();

    while(1)

    {

    ......

    }

    Then i find the value in the message ram is different : 0x60000001 for message 1 and 0x40000002 for message 2.The frame ID and type is correct. But the transmit data is still not correct, it always 0x00 0x00 0x00.......,and can not receive any data.

    So i block these statements in canTransmit() and canGetData() in can.c :

    /** - Setup IF1 for data transmission
        *     - Wait until IF1 is ready for use
        *     - Set IF1 control byte
        */
    //    while ((((node->IF1CMD & 0x0000FF00U) >> 8U) & 0x00000080U) == 0x00000080U)
    //    {
    // } /* Wait */

    //    node->IF1CMD  = (node->IF1CMD & 0xFF00FFFFU) | (0x87U << 16U);

        /** - Setup IF2 for reading data
        *     - Wait until IF1 is ready for use
        *     - Set IF1 control byte
        */
    //    while ((((node->IF2CMD & 0x0000FF00U) >> 8U) & 0x00000080U) == 0x00000080U)
    //    {
    // } /* Wait */

    //    node->IF2CMD = (node->IF2CMD & 0xFF00FFFF) | (0x17U << 16U);

     After that, the DCAN1 can transmit and receive the correct data.

    Now, i'am very confused about that.Is there any bugs in Halcogen3.05 or DCAN module ?

     

    Please help.

    Thank you.

    Regards

    Node

  • Hi Node,

    I will forward this to Halcogen team and get back to you as soon as possible.

    Thanks.

    Regards

    Jay

  • Hi Node,

    Currently I do not have your Microcontroller to check.

    Meanwhile, Why don't you check the example that comes with HALCoGen for other family say TMS570LS31x. Driver is pretty much same for both family of device.

    Open HALCoGen ( even with out pjt file), just go to Help --> Help Topic ( It will take you to #1x family Help file)  --> Go to Example --> See example_canCommunication.c.

    Regards
    Prathap