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.

LAUNCHXL-F280049C: can bus transmit and receive

Part Number: LAUNCHXL-F280049C
Other Parts Discussed in Thread: LAUNCHXL-F280025C

Please find below further information provided to the case:

I have the development board Launchxl-F280049C. I am trying to use can bus as a receiver and transmitter. I used two examples. can_ex1_loopback and can_ex5_transmit_receive.

With can_ex1_loopback I do not think I can sense the can-Lo and can-Hi so that is why I chose to use can_ex5_transmit_receive

I have an oscilloscope to sense the can-Hi and can-Lo signals. I am also using arduino uno with mcp2515 for debugging the can bus and for analysis. With arduino uno I can transmit can messages and I can see the signals on oscilloscope.

with Launchxl-F280049C and using the can_ex5_transmit_receive example, I am still not able to sense can-Lo or can-Hi signals on the J14. when debugging, I see that it is stuck in "while(txMsgSuccessful);" when using #define transmit and it is stuck in the line "while(rxMsgCount)" when it is working in receive mode

  • Ahmad, 

    The pin configurations are different for Launchpad as the example by default defines the pin config for Control Card. 

    To enable the right pin config, go to the device folder -> device.h file and make the proper define:

    #define _LAUNCHXL_F280049C

    This should ensure that you are able to see the signals on an oscilloscope on the right pins.

    Thanks.

  • Ahmad, 

    An alternate and better way to do this is while building the example, go to Project -> Build Configurations -> Set Active -> CPU1_LAUNCHXL_RAM/FLASH

    That will enable the right pin configurations on it's own.

    Thanks.

  • Hi Sahil,

    Thank you so much. Yes you are right. They are different. I did both. Firstly #define _LAUNCHXL_F280049C and then Project -> Build Configurations -> Set Active -> CPU1_LAUNCHXL_FLASH. I am still not able to sense the can-Lo, can-Hi

  • Ahmad, 

    Are you working directly on the examples or has the code been modified? If yes, can you please provide the code here?

    You can also check out the following app note for common debugging strategies: www.ti.com/lit/SPRACE5

    Thanks.

  • Hi Sahil,

    Good day! I am helping Ahmad Sasah to post the question and response here. 

    To analyze whether the problem is with the hardware or with the software, I used another development board (Launchxl-F280025C). Now I can sense the can-Lo and can-Hi signals. So it seems that there is a hardware issue with my development board (Launchxl-F280049C).
    Now I have another problem with (Launchxl-F280025C) which I do not think that this is specific for this board. I have two arduino uno boards with mcp2515. I can transmit and receive correctly can messages between the two boards by using one arduino uno board as a transmitter and the other one as a receiver. But when trying to send can messages from Launcxl-F280025C (transmitter) to arduino uno (receiver) then I receive always wrong messages. So it seems that the problem is with the bitrate and the clock frequency.

    Below is my arduino code (receiver)


    #include <SPI.h>
    #include "mcp_can.h"

    const int spiCSPin = 10;
    const int ledPin = 2;
    boolean ledON = 1;

    MCP_CAN CAN(spiCSPin);

    void setup()
    {
    Serial.begin(115200);
    pinMode(ledPin,OUTPUT);
    while (CAN_OK != CAN.begin(CAN_125KBPS,MCP_16MHz))
    {
    Serial.println("CAN BUS Init Failed");
    delay(100);
    }
    Serial.println("CAN BUS Init OK!");
    }


    void loop()
    {
    unsigned char len = 0;
    unsigned char buf[4];

    if(CAN_MSGAVAIL == CAN.checkReceive())
    {
    CAN.readMsgBuf(&len, buf);
    Serial.println("len:");
    Serial.println(len);

    unsigned long canId = CAN.getCanId();

    Serial.println("-----------------------------");
    Serial.print("Data from ID: 0x");
    Serial.println(canId, HEX);

    for(int i = 0; i<len; i++)
    {
    Serial.print(buf[i]);
    Serial.print("\t");
    }
    Serial.println();
    }
    }

    --

    Regarding the bitrate I cannot have a communication when setting an equal bitrate between F280025 and arduino uno. I am defining bitrate in F280025 using the function:
    CAN_setBitRate(CANA_BASE, DEVICE_SYSCLK_FREQ, 50000, 20);
    And to setup a message:
    CAN_setupMessageObject(CANA_BASE, TX_MSG_OBJ_ID, 0x15555555, CAN_MSG_FRAME_EXT, CAN_MSG_OBJ_TYPE_TX, 0, CAN_MSG_OBJ_TX_INT_ENABLE, MSG_DATA_LENGTH);
    I am using the following as txMsgData
    txMsgData[0]=0x11; txMsgData[1]=0x22; txMsgData[2]=0x33; txMsgData[3]=0x44;
    And in arduino I am receiving:
    Data from ID: 0x6B5
    43 88 165 43 88 165 43 88 131 0 0 0 0 73 1 169 0 214 0 150 1 7 1 229 0 249 0 69 110 116 101 114 32 115 101 116 116 105 110 103 32 109 111 100 101 32 102 97 105 108 13 10 0 69 110 116 101 114 32 115 101 116 116 105 110 103 32 109 111 100 101 32 115 117 99 99 101 115 115 32 13 10 0 115 101 116 32 114
    So the can ID and message data are wrong

    Best regards,

    Jonathan

  • Jonathan, 

    We are looking into it and will get back to you soon.

    Thanks.

  • Hi Sahil,

    Here is another update from our customer.

    Using the oscilloscope with can decoding feature I was able to decode the CAN signal that is transmitted from F280025 correctly. Whether if it is extended frame or standard frame and by using the same bitrate i was getting the data messages and the frame id correctly. So I can say that it is an Arduino issue. If you have any suggestions about this problem or any clarification it would be nice. The question is did this happen because of the frequency, bitrate, arduino thing? Will this happen in the future if I connect another microcontroller as a receiver and vice versa?

    Best regards,

    Jonathan

  • Jonathan, 

    I apologise for the delay in the response, I was a little under the weather.

    As I understand it, you are able to successfully sense the can-Lo and can-Hi signals from the F280025 Launchpad and the message is being transmitted at the desired bit rate and msg ID as seen by the oscilloscope. 

    CAN.begin(CAN_125KBPS,MCP_16MHz)

    Is it here that the bitrate for the arduino is being set? What does it correspond to as per the oscilloscope? 

    There is very little information for me to go on here, so it would be great if you could share some relevant details.

    Thanks.

  • Reassigning this thread to another CAN expert to get you an answer.

  • You mention you are able to see the correct ID and data from the F280025 using an oscilloscope, so there is nothing wrong on the F280025 side. The data you see on the Arduino side is not from F250025. If the bit-rates are mismatched between the nodes, they would quickly go into bus-off. You will not never receive "wrong data" in CAN. Either you receive the correct data or you will receive nothing. I strongly urge you to look into my debug tips in www.ti.com/it/SPRACE5.

    while (CAN_OK != CAN.begin(CAN_125KBPS,MCP_16MHz))

    Does the above correspond to 125 kbps? If so, how will it work with F280025 which is configured for 500 kbps?

  • Thank you Sahil.

    Hi Hareesh,

    Thank you so much for the kind information. Yes, CAN_125KBPS corresponds to 125 KBPS. Because when configuring the Arduino to work with 500 KBPS then i receive nothing. Yes, it is an Arduino issue and not F280025 issue any more. And the data I am receiving on the oscilloscope is simply noise and it is not from the F280025. Interestingly when I configure two Arduinos to work together one as transmitter and the other one as receiver then they communicate without errors. Before closing this issue may I ask you your opinion: Would the problem be because Arduino Uno does not have CAN and it uses SPI through mcp2515 to send can messages?

  • The fact that the two Arduino boards communicate with each other tells me that there is no issue with the CAN interface on these boards. It is unlikely there is an issue with the Launchpad either. It is likely the problem is due to a bit-rate mismatch. Please set the bit-rate on the Launchpad to 125 kbps, since we know that bit-rate works on Arduino Uno. 

    CAN_setBitRate(CANA_BASE, DEVICE_SYSCLK_FREQ, 125000, 16);