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.

CAN bus is not working.

Other Parts Discussed in Thread: LAUNCHXL-F280025C, SYSCONFIG, C2000WARE

I have follow the CAN example "can_ex1_loopback.c" for the LAUNCHXL-F280025C. In this example the pin out configurations is as follow:

//CANA -> myCAN0 Pinmux
    GPIO_setPinConfig(GPIO_12_CANA_RX);
    GPIO_setPinConfig(GPIO_13_CANA_TX);

The problem is that the CAN transceiver in the LAUNCHXL-F280025C is connected to GPIO32 and GPIO33. When I change the pin configuration I don't see any data going out from GPIO33_CANA_TX.

Is there a special configuration that needs to be done in order to have the right configuration for the CAN bus using GPIO32 and GPIO33?

Best,

Wilson Martinez

  • Hi Wilson,

    I assume you made these changes:

        GPIO_setPinConfig(GPIO_33_CANA_RX);
        GPIO_setPinConfig(GPIO_32_CANA_TX);

    Other than this, you should not be needing to make any other configuration for the CAN pins.  By the way, TX should be GPIO32.

    Regards,

    Joseph

  • Joseph,

    Thanks for answering me. Yes, I have tried this configuration and it does not work.

    Also, yes, I did a mistake, TX is GPIO32.

    Do you know know what else could prevent this from working as it should be?

  • Hi Wilson,

    Did you use the Sysconfig tool to change the CAN RX/TX pin assignment?  In CCS10, I found that out that if i do not use Sysconfig to change the CAN channel assignment and recompile the code, the assignment reverts back to using the default CAN GPIO12/13  for RX/TX.  Anyhow, can_ex1_loopback.c really does not need the transceiver in order to run since TX data is fed back to internal RX buffer for the loopback function.  You only need the TX pin in order to have the capability to observe the CAN frame externally on a pin.  Can you also check GPIO13 to see if the CAN frame is coming out from that pin.

    I tried both configurations on my setup:

    with

        GPIO_setPinConfig(GPIO_12_CANA_RX);
        GPIO_setPinConfig(GPIO_13_CANA_TX);

    or with

        GPIO_setPinConfig(GPIO_33_CANA_RX);
        GPIO_setPinConfig(GPIO_32_CANA_TX);

    and for both configurations, i am able to scope out the waveform on CANA_TX pin.

    Regards,

    Joseph

  • Joseph

    Can I have your code and the jumper configuration for the LAUNCHXL-F280025C?

  • Hi Wilson,

    I used the code straight from the C2000Ware examples.  I did not have to modify anything in the code, except for the CAN GPIO assignments depending on the CAN pin assignments.  If you choose to use GPIO32 for CANTX, move S4 switch to position marked XCVR in the silkscreen (towards the bottom edge of the PCB) and CAN frames can be monitored in TP7 (pin 1 of S4).  If you choose to use GPIO13 for CANTX, CAN frame can be monitored in IO.13 on header J8.

    If you wrote your own code using "can_ex1_loopback.c" as your starting example, make sure to follow the functions in Device_init() as this contains proper setup of device clocks and enabling of peripheral clocks, specifically for the CAN module.

    Regards,

    Joseph

  • Joseph,

    Thank you so much. I was doing a mistake. I was trying to monitor the CAN frames on Headers with the S4 in the XCVR position. It is working now.

    Now I need to configure or set up the mailboxes of the CAN. Do you know if there is an example that I can follow to set the mailboxes?

    Another question is, why my LAUNCHXL-F280025C does not keep the programing if I reset the Launchpad or if I unplug/plug it from the power?

    Regards,

    Wilson

  • Hi Wilson,

    Great that you were able to observe the CAN frames with proper S4 setting.  As for mailbox setup, check on the example  "can_ex3_loopback_dma".  Look at how function CAN_setupMessageObject() is used.  The CAN module in device F28002x has 32 mailboxes (or objects) which you can use as transmit, receive, or a combination of both.  In this example, the transmit object (mailbox) is set as '1', while the receive mailbox is set as '2'.

    As for your second question, you might have loaded your code in RAM, hence program gets erased if you power cycle.  You have to program your code in flash so it will not get erased on power cycling.  To program the code in flash, right click on the project name in Project Explorer (in CCS Edit mode), then go to the bottom of the menu under Properties.  Under the Resource, choose General then under Configuration, choose CPU1_LAUNCHXL_FLASH from the pull-down menu.  This will automatically choose a linker that points to your code location in flash, then compile and load your code as usual.  Next time you do power cycling, code remains programmed and executed from flash.

    Hope this helps.

    Regards,

    Joseph

  • Joseph,

    Thank you so much for your help. The CAN is working finally. I have some questions though.

    I am using a device to monitor my can messages. The device Baud Rate is set to 500 kbps but if I set Bit Rate on the CAN to 500000 It does not work.

    I found out that Bit Rate = (Baud Rate * the number of bits) which in this case is 8 so,  Bit Rate = 500,000 * 8 = 4,000,000. This value did not match with the expected time per bit of 2 us.

    I did the following modification to the code:

    CAN_setBitRate(CAN_BASE, DEVICE_SYSCLK_FREQ, 2000000, 20);

    The value of 2,000,000 on the bitRate is matching with the bit time of 2 us and I am able to monitor the CAN message. At this point, this is the only modification I have done in the can_ex1_loopback.c example and it is working well.

    Something weird that is happening is that after flashing the code to the Launchpad the CCS is taking me to the device.c file indicating the following error:

    //*****************************************************************************
    //
    // Error handling function to be called when an ASSERT is violated
    //
    //*****************************************************************************
    void __error__(char *filename, uint32_t line)
    {
        //
        // An ASSERT condition was evaluated as false. You can use the filename and
        // line parameters to determine what went wrong.
        //
        ESTOP0;
    }

    I have to be clear that this is not preventing the firmware to run as it is expected but I do not know how to fix it.

    I  know that the bitRate = 2,000,000 is the cause of this error the following assert is not fulfilled (can.c): ASSERT(bitRate <= 1000000U);

    The question is why it is working well even though is not fulfilling this assertion?

    What I am doing wrong and how can I guarantee that the CAN communicates at a Baud Rate of 500,000?

    By the way. I followed your instructions but the code does not remain programmed and executed from flash after I reset the Launchpad or if I unplug/plug it from the power.

    Regards,

    Wilson

  • Hi Wilson,

    Sorry for the late response.  By the way, as soon as the thread is marked resolved, it is automatically closed by the system and i did not check that you posted another question on the same post.  In order to prevent delays on our responses, please post the different question in a new thread (not the closed one) to ensure timely response.

    Regards,

    Joseph