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.

Problem with CAN communication

Other Parts Discussed in Thread: HALCOGEN

I am a beginner, and i followed the youtube tutorial on how to use CAN messaging on a TMS570LS37X HDK that i have. I have CAN1 and CAN2 connected together, so that i can send from CAN1 and recieve from CAN2 on same board. There is no response on terminal. I tried to monitor bus using a Kvaser Leaf lite, but blank bus is displayed here as well.

my code:

#include "sys_common.h"

#include "system.h"

#include "can.h"

#include "sci.h"

#include "esm.h"

#define  D_SIZE 9

 

uint8  tx_data[D_SIZE]  = {'H','E','R','C','U','L','E','S','\0'};

uint8  rx_data[D_SIZE] = {0};

uint32 error = 0;

 

uint32 checkPackets(uint8 *src_packet,uint8 *dst_packet,uint32 psize);

void main(void)

{

    canInit(); /* can1 -> can2 */

    sciInit();

    canTransmit(canREG1, canMESSAGE_BOX1, tx_data);

 

    while(!canIsRxMessageArrived(canREG2, canMESSAGE_BOX1));

    canGetData(canREG2, canMESSAGE_BOX1, rx_data);  /* receive on can2  */

 

    sciSend(scilinREG, D_SIZE, rx_data);

 

    error = checkPackets(&tx_data[0],&rx_data[0],D_SIZE);

 

    while(1);

 

}

 

uint32 checkPackets(uint8 *src_packet,uint8 *dst_packet,uint32 psize)

{

   uint32 err=0;

   uint32 cnt=psize;

 

   while(cnt--)

   {

     if((*src_packet++) != (*dst_packet++))

     {

        err++;       

     }

   }

   return (err);

}

  • Hi Pushkar,

    Would you please shoot me a link to the video you're watching - I'm not familiar with it so it may help me to see it.

    I guess there's a couple questions - maybe not in the best order for you to check...

       1) have you tried checking the voltages on the CAN wires to see what they look like?   If you can do this with an oscilloscope that's best. 

      2) If there is activity - did you make sure that the Kvaser Leaf tool you are using is set to the matching bit rate.

      3) Did you make sure to follow the instructions in the example program and configure the CAN modules accordingly in the GUI?   Sometimes this gets missed.  There are usually config steps in the comments if it's a HalCoGen project and there is the same information with pictures in the HalCoGen help.

     4) Are your PLL settings correct - if not then the bit rate that you get out of the CAN controller might not be right.

  • Youtube link: http://www.youtube.com/watch?v=TrKQN-sor-s

    1) I have not scoped the CAN channels yet

    2) The Kvaser Leaf tool had the same data rate that i set in the Halcogen GUI for both send and recieve CAN channels

    3) I generated the code with halcogen, but i removed the comments before posting to shorten it

    4) I am not familiar with PLL settings, no tutorial mentioned any such thing.

    Thanks for the help and the prompt reply.

  • Never mind, i got it to run by changing Halcogen default directory to the same as CCS default directory.

    i was copy pasting before.

    Thanks.

  • Super,

    I didn't understand though what you mean by default directory ... what exactly did you have to do?