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.

CCS/LAUNCHXL-F280049C: What is the proper setup for external CAN communications?

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

Tool/software: Code Composer Studio

I can't get the CAN to transmit/receive to work for the LAUNCHXL-F280049C. I've looked through the relevant documents and code examples available on Code Composer, but I still can't get any output on the CAN pins. Can someone provide me with a tutorial and/or the proper steps for external CAN communication on the LAUNCHXL-F280049C?
An example would be much appreciated as well.

Thanks

  • Hi Muhammad,

    The launchpad has one transceiver for CAN A.
    If you are using the CAN Rx Tx GPIOs and not the CAN Transceiver pins then you need to connect external CAN Transceiver.
    For CANB you need to connect it to external CAN Transceiver.

    Thanks and Regards
    Harshmeet Singh
  • //#############################################################################
    // $TI Release: F28004x Support Library v1.05.00.00 $
    // $Release Date: Thu Oct 18 15:43:57 CDT 2018 $
    // $Copyright:
    // Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
    //
    // Redistribution and use in source and binary forms, with or without 
    // modification, are permitted provided that the following conditions 
    // are met:
    // 
    //   Redistributions of source code must retain the above copyright 
    //   notice, this list of conditions and the following disclaimer.
    // 
    //   Redistributions in binary form must reproduce the above copyright
    //   notice, this list of conditions and the following disclaimer in the 
    //   documentation and/or other materials provided with the   
    //   distribution.
    // 
    //   Neither the name of Texas Instruments Incorporated nor the names of
    //   its contributors may be used to endorse or promote products derived
    //   from this software without specific prior written permission.
    // 
    // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
    // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    // $
    //#############################################################################
    
    //
    // Included Files
    //
    #include "driverlib.h"
    #include "device.h"
    
    //
    // Defines
    //
    #define MSG_DATA_LENGTH    4
    #define TX_MSG_OBJ_ID    1
    
    //
    // Globals
    //
    volatile unsigned long i;
    volatile uint32_t txMsgCount = 0;
    volatile uint32_t errorFlag = 0;
    uint16_t txMsgData[4];
    
    //
    // Main
    //
    void main(void)
    {
        //
        // Initialize device clock and peripherals
        //
        Device_init();
    
        //
        // Initialize GPIO and configure GPIO pins for CANTX/CANRX
        // on module A and B
        //
        Device_initGPIO();
        GPIO_setPinConfig(DEVICE_GPIO_CFG_CANRXA);
        GPIO_setPinConfig(DEVICE_GPIO_CFG_CANTXA);
    
        //
        // Initialize the CAN controllers
        //
        CAN_initModule(CANA_BASE);
    
        //
        // Set up the CAN bus bit rate to 500kHz for each module
        // Refer to the Driver Library User Guide for information on how to set
        // tighter timing control. Additionally, consult the device data sheet
        // for more information about the CAN module clocking.
        //
        CAN_setBitRate(CANA_BASE, DEVICE_SYSCLK_FREQ, 500000, 16);
    
        //
        // Initialize the transmit message object used for sending CAN messages.
        // Message Object Parameters:
        //      CAN Module: A
        //      Message Object ID Number: 1
        //      Message Identifier: 0x95555555
        //      Message Frame: Extended
        //      Message Type: Transmit
        //      Message ID Mask: 0x0
        //      Message Object Flags: None
        //      Message Data Length: 4 Bytes
        //
        CAN_setupMessageObject(CANA_BASE, TX_MSG_OBJ_ID, 0x95555555,
                               CAN_MSG_FRAME_EXT, CAN_MSG_OBJ_TYPE_TX, 0,
                               CAN_MSG_OBJ_NO_FLAGS, MSG_DATA_LENGTH);
    
        //
        // Initialize the transmit message object data buffer to be sent
        //
        txMsgData[0] = 0x78;
        txMsgData[1] = 0x56;
        txMsgData[2] = 0x34;
        txMsgData[3] = 0x12;
    
        //
        // Start CAN module A and B operations
        //
        CAN_startModule(CANA_BASE);
    
        //
        // Transmit messages from CAN-A to CAN-B
        //
        for(;;)
        {
            //
            // Transmit message
            //
            while(1) CAN_sendMessage(CANA_BASE, TX_MSG_OBJ_ID, MSG_DATA_LENGTH, txMsgData);
            txMsgCount++;
    
            //
            // Increment the value in the transmitted message data.
            //
            txMsgData[0] += 0x01;
            txMsgData[1] += 0x01;
            txMsgData[2] += 0x01;
            txMsgData[3] += 0x01;
            
            //
            // Reset data if exceeds a byte
            //
            if(txMsgData[0] > 0xFF)
            {
                txMsgData[0] = 0;
            }
            if(txMsgData[1] > 0xFF)
            {
                txMsgData[1] = 0;
            }
            if(txMsgData[2] > 0xFF)
            {
                txMsgData[2] = 0;
            }
            if(txMsgData[3] > 0xFF)
            {
                txMsgData[3] = 0;
            }         
        }
    }
    

    Hi Harshmeet,

    I'm currently trying to transmit using the CAN A transceiver pins, but I'm not reading any outputs from the pins upon running my code nor am I receiving anything on the receiving board. The only relevant thing that updates when I run my code is the IF1 register

    Regards,

    Muhammad

  • Muhammad,

    I presume you are trying the example from C2000ware?

    Two things to check:

    1. Launchpad uses GPIO32 & GPIO33 for CAN. Are you sure your project uses those two pins and not some other GPIO?
    2. Have you checked if the code does not configure the module in self-test mode?

    On a different note, please take a look at the debug tips in my app.note SPRA876. I wrote it for a different processor family, but the tips are applicable for any MCU with CAN.

  • I haven't heard from you and presume you were able to resolve the issue.