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.

TMS320F280049: CANB works properly only in test mode

Part Number: TMS320F280049
Other Parts Discussed in Thread: SN65HVD23

Tool/software:

I used syscfg to generate the driver code, and I referred to EX1, EX2, and EX5 in the routine, and the expected effect was that when I sent data from an external CAN analyzer, the CANB received an interrupt and replied with a message. But the actual effect is that I use a logic analyzer to directly observe the CANB transceiver pins (pin12 and pin13), and only the transmit pin in external loopback mode can observe the outgoing data, and only the data on the receiving pin in silent mode can cause the receive interruption.

here I insert the syscfg and some of my code:

/**
 * These arguments were used when this file was generated. They will be automatically applied on subsequent loads
 * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments.
 * @cliArgs --board "/boards/LAUNCHXL_F280049C" --context "system" --product "C2000WARE@4.03.00.00"
 * @versions {"tool":"1.20.0+3587"}
 */

/**
 * Import the modules used in this configuration.
 */
const can  = scripting.addModule("/driverlib/can.js", {}, false);
const can1 = can.addInstance();

/**
 * Write custom configuration values to the imported modules.
 */
can1.$name                   = "myCAN0";
can1.enableInterrupt         = true;
can1.registerInterrupts      = true;
can1.interruptFlags          = ["CAN_INT_IE0"];
can1.interruptLine           = ["CAN_GLOBAL_INT_CANINT0"];
can1.msgObjsUsed             = [1,2];
can1.can.can_rxPin.$assign   = "boosterpack1.3";
can1.can.can_txPin.$assign   = "boosterpack2.51";
can1.can0Int.enableInterrupt = true;
can1.msgObj1.$name           = "msgObj0";
can1.msgObj1.msgType         = "CAN_MSG_OBJ_TYPE_TX";
can1.msgObj1.flags           = ["CAN_MSG_OBJ_TX_INT_ENABLE"];
can1.msgObj1.msgLen          = 4;
can1.msgObj2.$name           = "msgObj1";
can1.msgObj2.flags           = ["CAN_MSG_OBJ_RX_INT_ENABLE"];

/**
 * Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future
 * version of the tool will not impact the pinmux you originally saw.  These lines can be completely deleted in order to
 * re-solve from scratch.
 */
can1.can.$suggestSolution = "CANB";

  • I regret your description of the problem is not clear. Please download the latest version of https://www.ti.com/tool/C2000WARE?keyMatch=c2000ware and try the examples "as is" without any modification. This will validate your hardware. If this step is not successful, please download my Application report http://www.ti.com/lit/SPRACE5 and read through the Debug tips carefully. Most CAN issues can be resolved by going through this checklist.

    I have created a video to help with the first communication project using DCAN: https://training.ti.com/getting-started-dcan-module.  Please take a look.

    Consolidated resource list: https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1033069/faq-what-kind-of-resources-does-ti-provide-to-help-with-can-and-canfd

  • Hi,

    I use a logic analyzer to directly observe the CANB transceiver pins (pin12 and pin13),

    Which bard are you using for your test? The CAN transceiver on F280049 launchpad is SN65HVD23 4DR, and it has 8 pins only. Did you probe the CANH and CANL, or CANTX and CANRX?

    In silent test mode, the CAN_TX is always HIGH, but it can detect the received message. 

    In loopback test mode, the TXed message can be monitored by CAN analyzer. 

    Have you run the example #5? It should work for transmit and receive on F280049 LP.

  • Hello!

    I'm not using an launchpad, I'm using my own board, it's probably a pattern like 280049-adum1281-TJA1044, and I use a logic analyzer to detect the line 280049 to the middle of the adum1281, I can try the EX5 with no modification or very little modification according to your suggestion

  • Thanks! I'll try the information you provided, I would like to know how can I describe the problem more clearly?

  • Hello!

    I've tried ex5 and I've made a few changes to change CANA to CANB, the associated pins are 12 and 13, but the test results are: regardless of whether the TRANSMIT macro is defined (i.e. test send and receive separately), it will always only trigger the first branch CAN_INT_IN0ID_STATUS in the isr, and will not trigger receive or send interruptions, what do you think about this situation?

    //#############################################################################
    //
    // FILE:   can_ex5_transmit_receive.c
    //
    // TITLE:   CAN Configuration for Transmit and Receive.
    //
    //! \addtogroup driver_example_list
    //! <h1> CAN Transmit and Receive Configurations </h1>
    //!
    //! This example shows the basic setup of CAN in order to transmit or receive
    //! messages on the CAN bus with a specific Message ID. The CAN Controller is
    //! configured according to the selection of the define.
    //!
    //! When the TRANSMIT define is selected, the CAN Controller acts as a
    //! Transmitter and sends data to the second CAN Controller connected
    //! externally.If TRANMSIT is not defined the CAN Controller acts as a Receiver
    //! and waits for message to be transmitted by the External CAN Controller.
    //! Refer to [Programming Examples and Debug Strategies for
    //! the DCAN Module](www.ti.com/lit/SPRACE5) for useful information about
    //! this example
    //!
    //! \note CAN modules on the device need to be connected to via CAN
    //!       transceivers.
    //!
    //! \b Hardware \b Required \n
    //!  - A C2000 board with CAN transceiver.
    //!
    //! \b External \b Connections \n
    //!  - ControlCARD CANA is on DEVICE_GPIO_PIN_CANTXA (CANTXA)
    //!  - and DEVICE_GPIO_PIN_CANRXA (CANRXA)
    //!
    //! \b Watch \b Variables \b Transmit \Configuration \n
    //!  - MSGCOUNT   - Adjust to set the number of messages
    //!  - txMsgCount - A counter for the number of messages sent
    //!  - txMsgData  - An array with the data being sent
    //!  - errorFlag  - A flag that indicates an error has occurred
    //!  - rxMsgCount - Has the initial value as No. of Messages to be received
    //!                 and decrements with each message.
    //!
    //
    //#############################################################################
    
    //
    // Included Files
    //
    #include "driverlib.h"
    #include "device.h"
    #include "app_sci.h"
    
    //
    // Comment to Make the CAN Controller work as a Receiver.
    //
    //#define TRANSMIT
    
    //
    // Defines
    //
    #ifdef TRANSMIT
    #define TX_MSG_OBJ_ID    1
    #else
    #define RX_MSG_OBJ_ID    1
    #endif
    #define MSG_DATA_LENGTH  4
    #define MSGCOUNT        10
    
    //
    // Globals
    //
    #ifdef TRANSMIT
    volatile uint32_t txMsgCount = 0;
    uint32_t txMsgSuccessful  = 1;
    uint16_t txMsgData[4];
    #else
    volatile uint32_t rxMsgCount = MSGCOUNT;
    uint16_t rxMsgData[4];
    #endif
    volatile unsigned long i;
    volatile uint32_t errorFlag = 0;
    
    //
    // Function Prototypes
    //
    __interrupt void canaISR(void);
    
    //
    // Main
    //
    void can_test(void)
    {
        GPIO_setPinConfig(GPIO_12_CANB_TX);
        GPIO_setPinConfig(GPIO_13_CANB_RX);
    
        //
        // Initialize the CAN controllers
        //
        CAN_initModule(CANB_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(CANB_BASE, DEVICE_SYSCLK_FREQ, 500000, 20);
    
        //
        // Enable interrupts on the CAN A peripheral.
        //
        CAN_enableInterrupt(CANB_BASE, CAN_INT_IE0 | CAN_INT_ERROR |
                            CAN_INT_STATUS);
    
        //
        // Interrupts that are used in this example are re-mapped to
        // ISR functions found within this file.
        // This registers the interrupt handler in PIE vector table.
        //
        Interrupt_register(INT_CANB0,&canaISR);
    
        //
        // Enable the CAN-A interrupt signal
        //
        Interrupt_enable(INT_CANB0);
    
        CAN_enableGlobalInterrupt(CANB_BASE, CAN_GLOBAL_INT_CANINT0);
    
    #ifdef TRANSMIT
        //
        // Initialize the transmit message object used for sending CAN messages.
        // Message Object Parameters:
        //      CAN Module: A
        //      Message Object ID Number: 1
        //      Message Identifier: 0x15555555
        //      Message Frame: Extended
        //      Message Type: Transmit
        //      Message ID Mask: 0x0
        //      Message Object Flags: None
        //      Message Data Length: 4 Bytes
        //
        CAN_setupMessageObject(CANB_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);
        //
        // Initialize the transmit message object data buffer to be sent
        //
        txMsgData[0] = 0x12;
        txMsgData[1] = 0x34;
        txMsgData[2] = 0x56;
        txMsgData[3] = 0x78;
    #else
        //
        // Initialize the receive message object used for receiving CAN messages.
        // Message Object Parameters:
        //      CAN Module: A
        //      Message Object ID Number: 1
        //      Message Identifier: 0x15555555
        //      Message Frame: Extended
        //      Message Type: Receive
        //      Message ID Mask: 0x0
        //      Message Object Flags: Receive Interrupt
        //      Message Data Length: 4 Bytes (Note that DLC field is a "don't care"
        //      for a Receive mailbox
        //
        CAN_setupMessageObject(CANB_BASE, RX_MSG_OBJ_ID, 0x15555555,
                               CAN_MSG_FRAME_EXT, CAN_MSG_OBJ_TYPE_RX, 0,
                               CAN_MSG_OBJ_RX_INT_ENABLE, MSG_DATA_LENGTH);
    #endif
    
        //
        // Start CAN module A operations
        //
        CAN_startModule(CANB_BASE);
    
    #ifdef TRANSMIT
        //
        // Transmit messages from CAN-A.
        //
        for(i = 0; i < MSGCOUNT; i++)
        {
            //
            // Check the error flag to see if errors occurred
            //
            if(errorFlag)
            {
            	dbgPrintf("estop\r\n");
                asm("   ESTOP0");
            }
    
            //
            // Transmit the message.
            //
            dbgPrintf("tx:0x%2x-0x%2x-0x%2x-0x%2x\r\n", txMsgData[0], txMsgData[1],
            											txMsgData[2], txMsgData[3]);
            CAN_sendMessage(CANB_BASE, TX_MSG_OBJ_ID, MSG_DATA_LENGTH,
                            txMsgData);
    
            //
            // Delay 0.25 second before continuing
            //
            DEVICE_DELAY_US(250000);
    
            while(txMsgSuccessful);
            //
            // 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;
            }
    
            //
            // Update the flag for next message.
            //
            txMsgSuccessful  = 1;
        }
    #else
        //
        // Loop to keep receiving data from another CAN Controller.
        //
        while(rxMsgCount)
        {
        }
    #endif
    
        //
        // Stop application after completion.
        //
        asm("   ESTOP0");
    }
    
    //
    // CAN A ISR - The interrupt service routine called when a CAN interrupt is
    //             triggered on CAN module A.
    //
    __interrupt void
    canaISR(void)
    {
        uint32_t status;
    
        //
        // Read the CAN-B interrupt status to find the cause of the interrupt
        //
        status = CAN_getInterruptCause(CANB_BASE);
    
        //
        // If the cause is a controller status interrupt, then get the status
        //
        if(status == CAN_INT_INT0ID_STATUS)
        {
        	dbgPrintf("int-status change\r\n");
            //
            // Read the controller status.  This will return a field of status
            // error bits that can indicate various errors.  Error processing
            // is not done in this example for simplicity.  Refer to the
            // API documentation for details about the error status bits.
            // The act of reading this status will clear the interrupt.
            //
            status = CAN_getStatus(CANB_BASE);
    
            //
            // Check to see if an error occurred.
            //
    #ifdef TRANSMIT
            if(((status  & ~(CAN_STATUS_TXOK)) != CAN_STATUS_LEC_MSK) &&
               ((status  & ~(CAN_STATUS_TXOK)) != CAN_STATUS_LEC_NONE))
    #else
            if(((status  & ~(CAN_STATUS_RXOK)) != CAN_STATUS_LEC_MSK) &&
               ((status  & ~(CAN_STATUS_RXOK)) != CAN_STATUS_LEC_NONE))
    #endif
            {
                //
                // Set a flag to indicate some errors may have occurred.
                //
                errorFlag = 1;
            }
        }
    #ifdef TRANSMIT
        else if(status == TX_MSG_OBJ_ID)
        {
        	dbgPrintf("int-transfer\r\n");
            //
            // Getting to this point means that the TX interrupt occurred on
            // message object 1, and the message TX is complete.  Clear the
            // message object interrupt.
            //
            CAN_clearInterruptStatus(CANB_BASE, TX_MSG_OBJ_ID);
    
            //
            // Increment a counter to keep track of how many messages have been
            // transmitted. In a real application this could be used to set flags to
            // indicate when a message is transmitted.
            //
            txMsgCount++;
    
            //
            // Since the message was transmitted, clear any error flags.
            //
            errorFlag = 0;
    
            //
            // Clear the message transmitted successful Flag.
            //
            txMsgSuccessful  = 0;
        }
    #else
        else if(status == RX_MSG_OBJ_ID)
        {
        	dbgPrintf("int-recv\r\n");
            //
            // Get the received message
            //
            CAN_readMessage(CANB_BASE, RX_MSG_OBJ_ID, rxMsgData);
            dbgPrintf("rx:0x%2x-0x%2x-0x%2x-0x%2x\r\n", rxMsgData[0], rxMsgData[1],
            											rxMsgData[2], rxMsgData[3]);
    
            //
            // Getting to this point means that the RX interrupt occurred on
            // message object 1, and the message RX is complete.  Clear the
            // message object interrupt.
            //
            CAN_clearInterruptStatus(CANB_BASE, RX_MSG_OBJ_ID);
    
            //
            // Decrement the counter after a message has been received.
            //
            rxMsgCount--;
    
            //
            // Since the message was received, clear any error flags.
            //
            errorFlag = 0;
        }
    #endif
        //
        // If something unexpected caused the interrupt, this would handle it.
        //
        else
        {
            //
            // Spurious interrupt handling can go here.
            //
        }
    
        //
        // Clear the global interrupt flag for the CAN interrupt line
        //
        CAN_clearGlobalInterruptStatus(CANB_BASE, CAN_GLOBAL_INT_CANINT0);
    
        //
        // Acknowledge this interrupt located in group 9
        //
        Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
    }
    
    //
    // End of File
    //
    

  • Hello,

    1. Does your board have CAN transceivers for CANA and CANB?

    2. Does your CAN network contain termination resistors (120ohms) ?

  • 1. Transceiver is required for each CAN controller (CAN-A and CAN-B)

    The CAN controller has TXD and RXD pins that are used for TX and RX. These pins are connected to the CAN transceiver for converting the digital signals to differential signals for the transmission of messages on the bus and vice-versa for the reception. 

    2. One 120 Ω termination resistor is required on both ends to prevent reflection of signals on the bus. 

    3. If the CAN nodes are on different PCB boards which have different power source and ground potential, a ground wire should be used to set a common ground for the nodes on the bus.

  • Can you please post the schematics of your CAN circuit? i.e. the connection of CAN pins to the transceiver etc. 

  • Yes, I have a CAN transceiver and termination resistor on my board, and I can only take a screenshot of the schematic of the CAN part due to the trade secrets involved, as shown below:

  • Okay, here's the schematic of the CAN section:

  • I use a logic analyzer to directly observe the CANB transceiver pins (pin12 and pin13),

    I didn't see pin 12 and pin 13 in your schematics

  • Your schematics shows pin 8 of U12 (STB) to be unconnected (floating). This pin needs to be connected to GND for normal operation.

  • please correct your schematics mentioned in Hareesh's message.

    TJA1044 transceiver supports two operating modes: normal and standby. When STB is pulled LOW, it operate in Normal mode. Since it has an internal pull-up resistor, STB is pulled HIGH when it is unconnected and the transceiver is in Standby mode.

  • Sorry, I mean gpio12 and gpio13, and we can ignore the backend of the circuit now, because I wrote a set of test code, and it passes the test of both CANA and CAMB in another board with 28377, but the same program doesn't work in CANB in 280049. Since the board wiring of the 28377 is: the CANA pin is pulled up to the external transceiver through 10k, and the CANB pin is directly connected to the external transceiver, so I disconnect the 280049 CANB pin to the back-end link, and also use the external transceiver, so that the hardware environment is almost exactly the same as the CANB of the 28377, unfortunately I still can't see any 280049 message through the CAN analyzer when the 28377 easily passed the test. I wonder if this could have something to do with the system clock? At present, the clock source of the 280049 is 25M*8/2, and I really don't understand the calculation of the baud rate in the routine and syscfg.

    Here I insert my test code, I only call the "can_test" function in the main()

    /*
     * Copyright (c) 2020 Texas Instruments Incorporated - http://www.ti.com
     * All rights reserved.
     *
     * 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.
     *
     */
    
    #include "cansyscfg.h"
    #include "driverlib.h"
    #include "device.h"
    #include "app_sci.h"
    
    #define MSG_DATA_LENGTH    4
    #define TX_MSG_OBJ_ID      1
    #define RX_MSG_OBJ_ID      2
    
    volatile uint32_t txMsgCount = 0;
    volatile uint32_t rxMsgCount = 0;
    volatile uint32_t errorFlag = 0;
    uint16_t txMsgData[2];
    uint16_t rxMsgData[4];
    uint32_t flg = 0;
    
    void ShowCanReg(uint32_t base)
    {
    	dbgPrintf("[CTL]:0x%04x-%04x\r\n", HWREG(base+0x0),HWREG(base+0x1));
    	dbgPrintf("[ES]:0x%04x-%04x\r\n", HWREG(base+0x4),HWREG(base+0x5));
    	dbgPrintf("[ERRC]:0x%04x-%04x\r\n", HWREG(base+0x8),HWREG(base+0x9));
    	dbgPrintf("[BTR]:0x%04x-%04x\r\n", HWREG(base+0xc),HWREG(base+0xd));
    	dbgPrintf("[INT]:0x%04x-%04x\r\n", HWREG(base+0x10),HWREG(base+0x11));
    	dbgPrintf("[TEST]:0x%04x-%04x\r\n", HWREG(base+0x14),HWREG(base+0x15));
    	dbgPrintf("[PEER]:0x%04x-%04x\r\n", HWREG(base+0x1c),HWREG(base+0x1d));
    	dbgPrintf("[REL]:0x%04x-%04x\r\n", HWREG_BP(base+0x20),HWREG_BP(base+0x21));
    	dbgPrintf("[RAM]:0x%04x-%04x\r\n", HWREG(base+0x40),HWREG(base+0x41));
    	dbgPrintf("[INT_EN]:0x%04x-%04x\r\n", HWREG(base+0x50),HWREG(base+0x51));
    	dbgPrintf("[INT_FLG]:0x%04x-%04x\r\n", HWREG(base+0x54),HWREG(base+0x55));
    	dbgPrintf("[ABOTR]:0x%04x-%04x\r\n", HWREG(base+0x80),HWREG(base+0x81));
    	dbgPrintf("[TXRQX]:0x%04x-%04x\r\n", HWREG(base+0x84),HWREG(base+0x85));
    	dbgPrintf("[TXRQ21]:0x%04x-%04x\r\n", HWREG(base+0x88),HWREG(base+0x89));
    	dbgPrintf("[NDATX]:0x%04x-%04x\r\n", HWREG(base+0x98),HWREG(base+0x99));
    	dbgPrintf("[NDAT21]:0x%04x-%04x\r\n", HWREG(base+0x9c),HWREG(base+0x9d));
    	dbgPrintf("[IPENX]:0x%04x-%04x\r\n", HWREG(base+0xac),HWREG(base+0xad));
    	dbgPrintf("[IPEN21]:0x%04x-%04x\r\n", HWREG(base+0xb0),HWREG(base+0xb1));
    	dbgPrintf("[MVALX]:0x%04x-%04x\r\n", HWREG(base+0xc0),HWREG(base+0xc1));
    	dbgPrintf("[MVAL21]:0x%04x-%04x\r\n", HWREG(base+0xc4),HWREG(base+0xc5));
    	dbgPrintf("[INT_MUX]:0x%04x-%04x\r\n", HWREG(base+0xd8),HWREG(base+0xd9));
    	dbgPrintf("[IF1CMD]:0x%04x-%04x\r\n", HWREG(base+0x100),HWREG(base+0x101));
    	dbgPrintf("[IF1MSK]:0x%04x-%04x\r\n", HWREG(base+0x104),HWREG(base+0x105));
    	dbgPrintf("[IF1ARB]:0x%04x-%04x\r\n", HWREG(base+0x108),HWREG(base+0x109));
    	dbgPrintf("[IF1MCTL]:0x%04x-%04x\r\n", HWREG(base+0x10c),HWREG(base+0x10d));
    	dbgPrintf("[IF1DATA1]:0x%04x-%04x\r\n", HWREG(base+0x110),HWREG(base+0x111));
    	dbgPrintf("[IF1DATA2]:0x%04x-%04x\r\n", HWREG(base+0x114),HWREG(base+0x115));
    	dbgPrintf("[IF2CMD]:0x%04x-%04x\r\n", HWREG(base+0x120),HWREG(base+0x121));
    	dbgPrintf("[IF2MSK]:0x%04x-%04x\r\n", HWREG(base+0x124),HWREG(base+0x125));
    	dbgPrintf("[IF2ARB]:0x%04x-%04x\r\n", HWREG(base+0x128),HWREG(base+0x129));
    	dbgPrintf("[IF2MCTL]:0x%04x-%04x\r\n", HWREG(base+0x12c),HWREG(base+0x12d));
    	dbgPrintf("[IF2DATA1]:0x%04x-%04x\r\n", HWREG(base+0x130),HWREG(base+0x131));
    	dbgPrintf("[IF2DATA2]:0x%04x-%04x\r\n", HWREG(base+0x134),HWREG(base+0x135));
    }
    //
    ////*****************************************************************************
    ////
    //// Board Configurations
    //// Initializes the rest of the modules. 
    //// Call this function in your application if you wish to do all module 
    //// initialization.
    //// If you wish to not use some of the initializations, instead of the 
    //// Board_init use the individual Module_inits
    ////
    ////*****************************************************************************
    //void can_test()
    //{
    //	EALLOW;
    //
    //	PinMux_init();
    //	CAN_init();
    //	INTERRUPT_init();
    //
    //	EDIS;
    //    txMsgData[0] = 0x1234;
    //    txMsgData[1] = 0x5678;
    //	ShowCanReg(CANB_BASE);
    //	
    //	for(;;)
    //	{
    //		//
    //		// Check the error flag to see if errors occurred
    //		//
    //		if(errorFlag)
    //		{
    //			dbgPrintf("estop\r\n");
    //			asm("	ESTOP0");
    //		}
    //
    ////		while(!flg);
    ////		dbgPrintf("tx:%04x-%04x\r\n", rxMsgData[0], rxMsgData[1]);
    ////		CAN_sendMessage(CANB_BASE, TX_MSG_OBJ_ID, MSG_DATA_LENGTH/2,
    ////						  rxMsgData);
    ////		flg = 0;
    //		
    //		//
    //		// Verify that the number of transmitted messages equal the number of
    //		// messages received before sending a new message
    //		//
    //		  if(txMsgCount == rxMsgCount)
    //		  {
    //			dbgPrintf("tx:%04x-%04x\r\n", txMsgData[0], txMsgData[1]);
    //			CAN_sendMessage(CANB_BASE, TX_MSG_OBJ_ID, MSG_DATA_LENGTH,
    //							  txMsgData);
    //		  }
    //		  else
    //		  {
    //			  errorFlag = 1;
    //		  }
    //
    //		//
    //		// Delay 1 second before continuing
    //		//
    //		  DEVICE_DELAY_US(2000000);
    //
    //		//
    //		// Increment the value in the transmitted message data.
    //		//
    //		txMsgData[0] += 0x01;
    //		txMsgData[1] += 0x01;
    ////		if(CAN_readMessage(CANB_BASE, RX_MSG_OBJ_ID, rxMsgData))
    ////		{
    ////			dbgPrintf("rx:%04x-%04x-%04x-%04x\r\n", rxMsgData[0], rxMsgData[1],
    ////												rxMsgData[2], rxMsgData[3]);
    ////			CAN_sendMessage(CANB_BASE, TX_MSG_OBJ_ID, 2, rxMsgData);
    ////		}
    //		rxMsgCount++;
    //		txMsgCount++;
    //
    //		//
    //		// Reset data if exceeds a byte
    //		//
    //		if(txMsgData[0] > 0xFFFF)
    //		{
    //			txMsgData[0] = 0;
    //		}
    //		if(txMsgData[1] > 0xFFFF)
    //		{
    //			txMsgData[1] = 0;
    //		}
    //	}
    //}
    void can_test()
    {
    	EALLOW;
    	GPIO_setPinConfig(myCAN0_CANRX_PIN_CONFIG);
    	GPIO_setPadConfig(myCAN0_CANRX_GPIO, GPIO_PIN_TYPE_STD | GPIO_PIN_TYPE_PULLUP);
    	GPIO_setQualificationMode(myCAN0_CANRX_GPIO, GPIO_QUAL_ASYNC);
    
    	GPIO_setPinConfig(myCAN0_CANTX_PIN_CONFIG);
    	GPIO_setPadConfig(myCAN0_CANTX_GPIO, GPIO_PIN_TYPE_STD | GPIO_PIN_TYPE_PULLUP);
    	GPIO_setQualificationMode(myCAN0_CANTX_GPIO, GPIO_QUAL_ASYNC);
    	{
    		CAN_initModule(myCAN0_BASE);
    		//
    		// 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_setBitTiming(myCAN0_BASE, 7, 0, 15, 7, 3);
    		//
    		// Enable CAN Interrupts
    		//
    		CAN_enableInterrupt(myCAN0_BASE, CAN_INT_ERROR|CAN_INT_IE0);
    		CAN_enableGlobalInterrupt(myCAN0_BASE, CAN_GLOBAL_INT_CANINT0);
    		CAN_setInterruptMux(myCAN0_BASE, 0);
    		CAN_startModule(myCAN0_BASE);
    	}
    	EDIS;
    	{
    		txMsgData[0] = 0x1234;
    		txMsgData[0] = 0x5678;
    		CAN_setupMessageObject(CANB_BASE, 1, 1, CAN_MSG_FRAME_STD,CAN_MSG_OBJ_TYPE_TX, 0, CAN_MSG_OBJ_TX_INT_ENABLE,4);
    		while(1)
    		{
    			dbgPrintf("tx:%04x-%04x\r\n", txMsgData[0], txMsgData[1]);
    			CAN_sendMessage(CANB_BASE, 1, MSG_DATA_LENGTH/2,
    							  txMsgData);
    			DEVICE_DELAY_US(2000000);
    		}
    	}
    }
    //*****************************************************************************
    //
    // PINMUX Configurations
    //
    //*****************************************************************************
    void PinMux_init()
    {
    	//
    	// PinMux for modules assigned to CPU1
    	//
    	
    	//
    	// CANB -> myCAN0 Pinmux
    	//
    	GPIO_setPinConfig(myCAN0_CANRX_PIN_CONFIG);
    	GPIO_setPadConfig(myCAN0_CANRX_GPIO, GPIO_PIN_TYPE_STD | GPIO_PIN_TYPE_PULLUP);
    	GPIO_setQualificationMode(myCAN0_CANRX_GPIO, GPIO_QUAL_ASYNC);
    
    	GPIO_setPinConfig(myCAN0_CANTX_PIN_CONFIG);
    	GPIO_setPadConfig(myCAN0_CANTX_GPIO, GPIO_PIN_TYPE_STD | GPIO_PIN_TYPE_PULLUP);
    	GPIO_setQualificationMode(myCAN0_CANTX_GPIO, GPIO_QUAL_ASYNC);
    
    
    }
    
    //*****************************************************************************
    //
    // CAN Configurations
    //
    //*****************************************************************************
    void CAN_init(){
    	myCAN0_init();
    }
    
    void myCAN0_init(){
    	CAN_initModule(myCAN0_BASE);
    	//
    	// 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_selectClockSource(myCAN0_BASE, CAN_CLOCK_SOURCE_XTAL);
    //	CAN_setBitTiming(myCAN0_BASE, 7, 0, 15, 7, 3);
        CAN_setBitRate(CANA_BASE, DEVICE_SYSCLK_FREQ, 1000000, 20);
    	//
    	// Enable CAN Interrupts
    	//
    	CAN_enableInterrupt(myCAN0_BASE, CAN_INT_IE0);
    	CAN_enableGlobalInterrupt(myCAN0_BASE, CAN_GLOBAL_INT_CANINT0);
    	//
    	// Initialize the transmit message object used for sending CAN messages.
    	// Message Object Parameters:
    	//      Message Object ID Number: 1
    	//      Message Identifier: 0
    	//      Message Frame: CAN_MSG_FRAME_STD
    	//      Message Type: CAN_MSG_OBJ_TYPE_TX
    	//      Message ID Mask: 0
    	//      Message Object Flags: CAN_MSG_OBJ_TX_INT_ENABLE
    	//      Message Data Length: 4 Bytes
    	//
    	CAN_setupMessageObject(myCAN0_BASE, 1, myCAN0_MessageObj1_ID, CAN_MSG_FRAME_STD,CAN_MSG_OBJ_TYPE_TX, 0, CAN_MSG_OBJ_TX_INT_ENABLE,4);
    	//
    	// Initialize the transmit message object used for sending CAN messages.
    	// Message Object Parameters:
    	//      Message Object ID Number: 2
    	//      Message Identifier: 0
    	//      Message Frame: CAN_MSG_FRAME_STD
    	//      Message Type: CAN_MSG_OBJ_TYPE_RX
    	//      Message ID Mask: 0
    	//      Message Object Flags: CAN_MSG_OBJ_RX_INT_ENABLE
    	//      Message Data Length: 0 Bytes
    	//
    	CAN_setupMessageObject(myCAN0_BASE, 2, myCAN0_MessageObj2_ID, CAN_MSG_FRAME_STD,CAN_MSG_OBJ_TYPE_RX, 0, CAN_MSG_OBJ_RX_INT_ENABLE,0);
    	CAN_setInterruptMux(myCAN0_BASE, 0);
    	//
    	// Start CAN module operations
    	//
    //	CAN_enableTestMode(myCAN0_BASE, CAN_TEST_EXL);
    	CAN_startModule(myCAN0_BASE);
    }
    
    //*****************************************************************************
    //
    // INTERRUPT Configurations
    //
    //*****************************************************************************
    void INTERRUPT_init(){
    	
    	// Interrupt Setings for INT_myCAN0_0
    	Interrupt_register(INT_myCAN0_0, &INT_myCAN0_0_ISR);
    	Interrupt_enable(INT_myCAN0_0);
    	
    	// Interrupt Setings for INT_myCAN0_1
    //	Interrupt_register(INT_myCAN0_1, &INT_myCAN0_1_ISR);
    //	Interrupt_disable(INT_myCAN0_1);
    }
    
    __interrupt void
    INT_myCAN0_0_ISR(void)
    {
        uint32_t status;
    
        //
        // Read the CAN interrupt status to find the cause of the interrupt
        //
        status = CAN_getInterruptCause(CANB_BASE);
    
        //
        // If the cause is a controller status interrupt, then get the status
        //
        if(status == CAN_INT_INT0ID_STATUS)
        {
            //
            // Read the controller status.  This will return a field of status
            // error bits that can indicate various errors.  Error processing
            // is not done in this example for simplicity.  Refer to the
            // API documentation for details about the error status bits.
            // The act of reading this status will clear the interrupt.
            //
    		dbgPrintf("test14\r\n");
            status = CAN_getStatus(CANB_BASE);
    
            //
            // Check to see if an error occurred.
            //
            if(((status  & ~(CAN_STATUS_TXOK | CAN_STATUS_RXOK)) != 7) &&
               ((status  & ~(CAN_STATUS_TXOK | CAN_STATUS_RXOK)) != 0))
            {
                //
                // Set a flag to indicate some errors may have occurred.
                //
                errorFlag = 1;
            }
        }
    
        //
        // Check if the cause is the transmit message object 1
        //
        else if(status == TX_MSG_OBJ_ID)
        {
            //
            // Getting to this point means that the TX interrupt occurred on
            // message object 1, and the message TX is complete.  Clear the
            // message object interrupt.
            //
    		dbgPrintf("test15\r\n");
            CAN_clearInterruptStatus(CANB_BASE, TX_MSG_OBJ_ID);
    
            //
            // Increment a counter to keep track of how many messages have been
            // sent.  In a real application this could be used to set flags to
            // indicate when a message is sent.
            //
            txMsgCount++;
    
            //
            // Since the message was sent, clear any error flags.
            //
            errorFlag = 0;
        }
    
        //
        // Check if the cause is the receive message object 2
        //
        else if(status == RX_MSG_OBJ_ID)
        {
            //
            // Get the received message
            //
    		dbgPrintf("test16\r\n");
            CAN_readMessage(CANB_BASE, RX_MSG_OBJ_ID, rxMsgData);
    		dbgPrintf("rx:%02x-%02x-%02x-%02x\r\n", rxMsgData[0], rxMsgData[1],
    												rxMsgData[2], rxMsgData[3]);
    		flg = 1;
    		rxMsgData[0] += 1;
    		rxMsgData[1] += 1;
    
            //
            // Getting to this point means that the RX interrupt occurred on
            // message object 2, and the message RX is complete.  Clear the
            // message object interrupt.
            //
            CAN_clearInterruptStatus(CANB_BASE, RX_MSG_OBJ_ID);
    
            //
            // Increment a counter to keep track of how many messages have been
            // received. In a real application this could be used to set flags to
            // indicate when a message is received.
            //
            rxMsgCount++;
    
            //
            // Since the message was received, clear any error flags.
            //
            errorFlag = 0;
        }
    
        //
        // If something unexpected caused the interrupt, this would handle it.
        //
        else
        {
            //
            // Spurious interrupt handling can go here.
            //
        }
    
        //
        // Clear the global interrupt flag for the CAN interrupt line
        //
        CAN_clearGlobalInterruptStatus(CANB_BASE, CAN_GLOBAL_INT_CANINT0);
    
        //
        // Acknowledge this interrupt located in group 9
        //
    	dbgPrintf("test18\r\n");
        Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
    }
    
    

  • Debugging your code is not something we can support on e2e.

    We have given you enough pointers to resolve the issue (especially the STB connection on the transceiver).

  • Okay thank you! I'll consider the connection of stb and try to solve it