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_ex4_simple_transmit test

Part Number: LAUNCHXL-F280049C


Dear team,

I used 28379d launchpad(with USB-CAN) to test can_ex4_simple_transmit at first. It runs well. The USB-CAN software can receive the packet.

And then, i used the code (can_ex4_simple_transmit ) with 280049 launchpad. I changed the IO setting and added "_LAUNCHXL_F280049C".

#define DEVICE_GPIO_CFG_CANRXA GPIO_33_CANA_RX // "pinConfig" for CANA RX
#define DEVICE_GPIO_CFG_CANTXA GPIO_32_CANA_TX // "pinConfig" for CANA TX

It showed that 280049C can transmit, but the USB-CAN software can NOT receive the packet. What did i miss?

Please help to check it.

//#############################################################################
//
// FILE:   can_ex4_simple_transmit.c
//
// TITLE:   CAN simple External Transmit Example
//
//! \addtogroup driver_example_list
//! <h1> CAN-A External Transmit </h1>
//!
//! This example initializes CAN module A for external communication.
//! CAN-A module is setup to transmit data for "n" number of times,
//! where "n" is the value of TXCOUNT. Another CAN node configured for the
//! same bit-rate is needed to provide the ACK. No interrupts are used.
//!
//! \b Hardware \b Required \n
//!  - A C2000 board with CAN transceiver and another CAN node configured
//!    for the same bit-rate to provide the ACK.
//!
//! \b Watch \b Variables \n
//!  - TXCOUNT - Adjust to set the number of messages to be transmitted
//!  - txMsgCount - A counter for the number of messages sent
//!  - txMsgData - An array with the data being sent
//!
//
//#############################################################################
// $TI Release: F2837xS Support Library v3.12.00.00 $
// $Release Date: Fri Feb 12 19:06:50 IST 2021 $
// $Copyright:
// Copyright (C) 2014-2021 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 TXCOUNT  100000
#define MSG_DATA_LENGTH    8
#define TX_MSG_OBJ_ID      1

//
// Globals
//
volatile unsigned long i;
volatile uint32_t txMsgCount = 0;
uint16_t txMsgData[8];

//
// Main
//
void main(void)
{
    //
    // Initialize device clock and peripherals
    //
    Device_init();

    //
    // Initialize GPIO and configure GPIO pins for CANTX/CANRX
    // on module A
    //
    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] = 0x01;
    txMsgData[1] = 0x23;
    txMsgData[2] = 0x45;
    txMsgData[3] = 0x67;
    txMsgData[4] = 0x89;
    txMsgData[5] = 0xAB;
    txMsgData[6] = 0xCD;
    txMsgData[7] = 0xEF;

    //
    // Start CAN module A operations
    //
    CAN_startModule(CANA_BASE);

    //
    // Transmit messages from CAN-A
    //
    while(1)
    //
    // Comment for infinite transmissions
    //
    //for(i = 0; i < TXCOUNT; i++)
    //
    {
        CAN_sendMessage(CANA_BASE, TX_MSG_OBJ_ID, MSG_DATA_LENGTH, txMsgData);

        //
        // Poll TxOk bit in CAN_ES register to check completion of transmission
        //
        while(((HWREGH(CANA_BASE + CAN_O_ES) & CAN_ES_TXOK)) !=  CAN_ES_TXOK)
        {
            txMsgCount++;
        }
    }
    //
    // Stop application
    //
    asm("   ESTOP0");
}

//
// End of File
//

  • Susan,

                  In CAN, transmission is not considered successful, unless the reception is successful. Reception is considered successful when at least one node received the transmitted frame without any errors and transmitted the ACK bit to the transmitter. I don’t understand how txMsgCount could have incremented without the reception being successful (by which I mean the reception should have been monitored in the CAN bus analyzer – I think you are using a tool called EmbeddedDebug v2.0). 

    Please download my Application report http://www.ti.com/lit/sprace5 and look at the Debug tips provided. Most CAN issues can be resolved by going through this checklist. Specifically, capture the activity at CANTX pin and verify the bit-rate.

  • In CAN, transmission is not considered successful, unless the reception is successful.

    But the txMsgCount can still increase even the EmbeddedDebug v2.0 do NOT show the received packet when i tested 280049 launchpad. Why?

    EmbeddedDebug v2.0 run well when i used 28379D launchpad.

    //
    // Poll TxOk bit in CAN_ES register to check completion of transmission
    //
    while(((HWREGH(CANA_BASE + CAN_O_ES) & CAN_ES_TXOK)) != CAN_ES_TXOK)
    {
    txMsgCount++;
    }

    Please download my Application report http://www.ti.com/lit/sprace5 and look at the Debug tips provided.

    I saw the Application report and checked the IO setting of 280049 launchpad twice. But no luck.

  • But the txMsgCount can still increase even the EmbeddedDebug v2.0 do NOT show the received packet when i tested 280049 launchpad. Why?

    txMsgCount can increase only when some other node on the network provides an ACK. Is there another node on the network? I doubt it.

    I saw the Application report and checked the IO setting of 280049 launchpad twice.

    Did you check the CANTX pin or the CAN_H pin with scope? Did you see any activity?