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-F28377S: LaunchPad F28377S ----CAN configuration operated in normal mode (no test mode).

Part Number: LAUNCHXL-F28377S

Hi all

I would like to establish the communication between PC computer and LaunchPad F28377S. I spend a lot of time to do it. 

There are the hardware facts:

1) On the board is located the dedicated gold pins for CAN connection. This pins are (CAN-L, CAN-H and GND). Further there is the Bus Transceivers (SN65HVD234D). The output of this device are D (CAN Transmit data TXD ) and R (CAN Recive data RXD ). Via resistors R43 and R44  are connected into  processors pins: 76 (GPIO70 -- CANRxA) and  76 (GPIO 71-- CANTxA)

There are the software facts:

1) I analyzed examples from  ControlSuit for device type F2837xS.

    C:\ti\controlSUITE\device_support\F2837xS\v210\F2837xS_examples_Cpu1.

2) I wrote the documentation F2837xS-DRL-UG.pdf

3) Based on these information I develop the software for CAN as bellow (only CAN transmission functionality). 

I can not observe any information on CAN-L and CAN-H. Using scope I see only value for both signals around 2,5V.

So I am asking to help me with this problem. Please point me where I am wrong in my thinking and which way I have to go.

I will be waiting for your response.

Best regarst

//###########################################################################
#include "F28x_Project.h" // Device Headerfile and Examples Include File

#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_types.h"
#include "inc/hw_memmap.h"
#include "inc/hw_can.h"
#include "driverlib/can.h"

unsigned char txMsgData[4];

tCANMsgObject sTXCANMessage;

void main(void)

{
InitSysCtrl();

InitGpio();

GPIO_SetupPinMux(70, GPIO_MUX_CPU1, 1); //GPIO70 - CANRXA
GPIO_SetupPinOptions(70, GPIO_INPUT, GPIO_ASYNC);
GPIO_SetupPinMux(71, GPIO_MUX_CPU1, 1); //GPIO71 - CANTXA
GPIO_SetupPinOptions(71, GPIO_OUTPUT, GPIO_PUSHPULL);

CANInit(CANA_BASE);

//
//CANBitTimingSet(address of CAN, points to the structure with the clock parameters (pClkParams))
//

//
// Setup CAN source clock. Select option
// CANClkSourceSelect(base address of CAN, clock source) 0 - Selected CPU SYSCLKOUT
CANClkSourceSelect(CANA_BASE, 0);

//
// CANBitRateSet(base address of CAN, clock freq for CAN in Hz, bit rate)

CANBitRateSet(CANA_BASE, 200000000, 250000);

DINT;

InitPieCtrl();

IER = 0x0000;
IFR = 0x0000;


// pMsgObject
sTXCANMessage.ui32MsgID = 0x203; // either 11 or 29
//sTXCANMessage.ui32MsgIDMask = 0;//0x7F8; // NONE;
sTXCANMessage.ui32Flags = MSG_OBJ_TX_INT_ENABLE;
//sTXCANMessage.ui32Flags = 0;
sTXCANMessage.ui32MsgLen = 4;
sTXCANMessage.pucMsgData = txMsgData;

txMsgData[0] = 0x12;
txMsgData[1] = 0x34;
txMsgData[2] = 0x56;
txMsgData[3] = 0x78;

CANEnable(CANA_BASE);

for(;;)

{

txMsgData[0] = 0x12;
txMsgData[1] = 0x34;
txMsgData[2] = 0x56;
txMsgData[3] = 0x78;

//
// Transmit Message
//CANA_BASE base address of CANA
//ObjID---object number to configuration 1-32 (Mail boxes)
//pMsgObject-----pointer to a structure containing massage object settings,
//eMsgType-------indicate the type of message for object);
//

CANMessageSet(CANA_BASE,2, &sTXCANMessage,MSG_OBJ_TYPE_TX);

DELAY_US(1000 * 250);

}

}

  • Have you tried running the Controlsuite example can_external_transmit.c (after modifying the GPIO assignments)? That would be a good place to start.
  • Additionally to what Hareesh mentioned, the controlSUITE examples are setup for the controlCARDs which have a different oscillator frequency. Make sure to add "_LAUNCHXL_F28377S" as a pre-defined symbol in your project. Details on this can be found in the "F2837xS-FRM-EX-UG", chapter 2, within the F2837xS v210 docs.

    Best Regards
    Chris
  • I tried run example can_external.c with GPIO modification. There are any satisfying results on CAN-H,CAN-L ports. Please note that on the LaunchPad we have only one transceiver.

    The example is develop for both CAN modules (CANA and CANB) of F28377S (not LaunchPad). Additionally both CAN modules on the device need to be connected to each other via CAN transceivers.

    Example initializes CAN module A and CAN module B for external communication. CAN-A module is setup to transmit incrementing data for to the CAN-B module. CAN-B module is setup to trigger an interrupt service routine (ISR) when data is received. An error flag will be set if the transmitted data doesn't match the received data

  • Try this:

     

    GPIO_SetupPinMux(70, GPIO_MUX_CPU1, 5); //GPIO70 - CANRXA

    GPIO_SetupPinOptions(70, GPIO_INPUT, GPIO_ASYNC);

    GPIO_SetupPinMux(71, GPIO_MUX_CPU1, 5); //GPIO71 - CANTXA

    GPIO_SetupPinOptions(71, GPIO_OUTPUT, GPIO_PUSHPULL);

  • Thank you very much.

    The settings (setupPinMux and SetupPinOption) for GPIO71  are working correctly. :):):). Thank you Hareesh :):):).

    Now I have another stage of CAN communication. I would like to receive the massage from CAN interface (103h frame). It doesn't work.

    My code is looks as follow. I don't know where is the problem. The wrong configuration for GPIO70 - CANRXA (actual number 5) or something wrong in my code. Maybe I have to add function or make reconfiguration. Thank you in advance for your strong support.

    --Definition

    unsigned char rxMsgData_103h[4];

    tCANMsgObject sRXCANMessage_103h;

    ---GPIO settings for RxCAN commmunication

    GPIO_SetupPinMux(70, GPIO_MUX_CPU1, 5); //GPIO70 - CANRXA
    GPIO_SetupPinOptions(70, GPIO_INPUT, GPIO_ASYNC);

    ---Initialization of 103h frame

    sRXCANMessage_103h.ui32MsgID = 0x103; // either 11 or 29
    //sRXCANMessage_103h.ui32MsgIDMask = 0;
    sRXCANMessage_103h.ui32Flags = MSG_OBJ_RX_INT_ENABLE;
    sRXCANMessage_103h.ui32MsgLen = 4;
    sRXCANMessage_103h.pucMsgData = rxMsgData_103h;

    ---Receive the frame from CAN

    CANMessageSet(CANA_BASE,3, &sRXCANMessage_103h, MSG_OBJ_TYPE_RX);

  • Looking at your post, it is hard to understand exactly what you are trying to do. This is my understanding. Let me know if anything is incorrect:

     

    1. You are trying to establish communication between the PC and the LaunchPAD. The PC probably has some kind of USB-CAN dongle.
    2.  The PC is sending a frame with the standard MSGID of 103h, which the LaunchPAD is not receiving. (or you believe is not being received)
    3.  Your code initializes the CANRX pin (GPIO70). If it doesn’t do it, it must initialize the CANTX (GPIO71) pin as well, ESPECIALLY if there are only two nodes on the network. Without an ACK from the receiver (LaunchPAD in this case) , a frame will never be received. Pls confirm you init GPIO71 as well for CANTX function.

     

    Questions:

     

    1. How did you come to the conclusion that data is not being received?
    2. Did you verify the correct reception of the frame up until the CANRXA pin? Can you provide a scope capture?
    3. Did you ensure that both transmitter and receiver are configured for the same bit-rate?
    4. How is the CAN bus on the PC side terminated?
    5. On the Launchpad side, what does your code do upon reception of a frame?

    1. You are trying to establish communication between the PC and the LaunchPAD. The PC probably has some kind of USB-CAN dongle.
    2. YES
    3.  The PC is sending a frame with the standard MSGID of 103h, which the LaunchPAD is not receiving. (or you believe is not being received) .
    4. Yes . I ma sending the frame to the Launchpad , but I don't  that this information is received via LaunchPad . So I try to do some test. I order to observe that data i received by controller  i used the LEDs (blue and red on the Launchpad). From the PC i Changed the value of data in 103h frame, In software i wrote the code, that will be react on this situation. (of data in CAN equal 10 power on Led and if not swich off)
    5.  Your code initializes the CANRX pin (GPIO70). If it doesn’t do it, it must initialize the CANTX (GPIO71) pin as well, ESPECIALLY if there are only two nodes on the network. Without an ACK from the receiver (LaunchPAD in this case) , a frame will never be received. Pls confirm you init GPIO71 as well for CANTX function.
    6. I initialized GPIO70 and GPIO71 for CAN_A
    7.  

    Questions:

     How did you come to the conclusion that data is not being received?

    Answer is above.

    Did you verify the correct reception of the frame up until the CANRXA pin? Can you provide a scope capture?

    Dd you ensure that both transmitter and receiver are configured for the same bit-rate?

    Not 100%

    How is the CAN bus on the PC side terminated?

    One CAN resistor(120R) is one the LaunchPad the second Is in cable between PC and LaunchPad.

    On the Launchpad side, what does your code do upon reception of a frame?

    Bellow the code

    //###########################################################################
    //
    // FILE: can_moje_transmit.c
    //
    //! - CANA is on GPIO71 (CANTXA) and GPIO70 (CANRXA)
    //
    //!
    //! \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
    //! - rxMsgCount - A counter for the number of messages received
    //! - txMsgData - An array with the data being sent
    //! - rxMsgData - An array with the data that was received
    //! - errorFlag - A flag that indicates an error has occurred
    //###########################################################################
    //###########################################################################

    //
    // Included Files
    //
    #include "F28x_Project.h" // Device Headerfile and Examples Include File
    #include <stdint.h>
    #include <stdbool.h>
    #include "inc/hw_types.h"
    #include "inc/hw_memmap.h"
    #include "inc/hw_can.h"
    #include "driverlib/can.h"

    //
    // Defines
    //

    #define RED_LED_GPIO 12 //RED GPIO 12
    #define BLUE_LED_GPIO 13 //BLUE GPIO 13

    //
    // Globals
    //

    //unsigned char txMsgData[4];
    //unsigned char rxMsgData[4];
    //tCANMsgObject sTXCANMessage;


    int unsigned a,b,c,d;

    //TX
    unsigned char txMsgData_203h[4];
    unsigned char txMsgData_205h[4];
    //RX
    unsigned char rxMsgData_103h[4];
    //unsigned char rxMsgData[4];

    tCANMsgObject sTXCANMessage_203h;
    tCANMsgObject sTXCANMessage_205h;

    tCANMsgObject sRXCANMessage_103h;
    //tCANMsgObject sRXCANMessage;

    //
    // Main
    //
    void main(void)
    {
    //
    // Initialize System Control:
    // PLL, WatchDog, enable Peripheral Clocks
    //
    InitSysCtrl();

    //
    // Initialize GPIO and configure GPIO pins for CANTX/CANRX
    // on module A and B
    //
    InitGpio();

    //
    // Setup GPIO pin mux for CAN-A TX/RX
    //

    GPIO_SetupPinMux(70, GPIO_MUX_CPU1, 5); //GPIO70 - CANRXA
    GPIO_SetupPinOptions(70, GPIO_INPUT, GPIO_ASYNC);
    GPIO_SetupPinMux(71, GPIO_MUX_CPU1, 5); //GPIO71 - CANTXA
    GPIO_SetupPinOptions(71, GPIO_OUTPUT, GPIO_PUSHPULL);

    //
    // Setup GPIO pin mux for LEDs
    //
    GPIO_SetupPinMux(RED_LED_GPIO, GPIO_MUX_CPU1, 0);
    GPIO_SetupPinOptions(RED_LED_GPIO, GPIO_OUTPUT, GPIO_PUSHPULL);

    GPIO_SetupPinMux(BLUE_LED_GPIO, GPIO_MUX_CPU1, 0);
    GPIO_SetupPinOptions(BLUE_LED_GPIO, GPIO_OUTPUT, GPIO_PUSHPULL);

    //
    // Initialize the CAN controllers
    // CANInit(based adress of CAN)
    CANInit(CANA_BASE);

    //
    //CANBitTimingSet(adress of CAN, points to the structure with the clock parameters (pClkParams))
    //

    //
    // Setup CAN source clock. Select option
    // CANClkSourceSelect(base adress of CAN, clock source) 0 - Selected CPU SYSCLKOUT
    CANClkSourceSelect(CANA_BASE, 0); // 500kHz CAN-Clock

    //
    //Setup comunication parameters for CAN
    // CANBitRateSet(base adress of CAN, clock freq for CAN in Hz, bit rate)
    CANBitRateSet(CANA_BASE, 200000000, 250000);

    //
    //Enable interrupts on the CAN B peripheral.
    //CANIntEnable(based adress of CAN,bit mask of the interrupt sources to be enable )
    //CAN_INT_ERROR | CAN_INT_STATUS there are kogical OR
    //
    //CANIntEnable(CANA_BASE, CAN_INT_ERROR | CAN_INT_STATUS);
    //CANIntEnable(CANA_BASE, CAN_INT_IE0);
    //CANIntEnable(CANA_BASE, CAN_INT_IE1);

    //
    // Clear all interrupts and initialize PIE vector table:
    // Disable CPU interrupts
    //
    DINT;

    //
    // Initialize the PIE control registers to their default state.
    // The default state is all PIE interrupts disabled and flags
    // are cleared.
    //
    InitPieCtrl();

    //
    // Disable CPU interrupts and clear all CPU interrupt flags
    //
    IER = 0x0000;
    IFR = 0x0000;

    ////////////////////////////////////////////////////////////////////////
    //WYSYLANIE CAN inicjalizacja
    ///////////////////////////////////////////////////////////////////////


    // INICJALIZACJA (wysylanie) USTAWIEN CAN DLA RAMKI 203h i 205h
    //frame_203h
    // pMsgObject
    sTXCANMessage_203h.ui32MsgID = 0x203; // either 11 or 29
    sTXCANMessage_203h.ui32Flags = MSG_OBJ_TX_INT_ENABLE;
    sTXCANMessage_203h.ui32MsgLen = 4;
    sTXCANMessage_203h.pucMsgData = txMsgData_203h;

    //205h frame
    //pMsgObject_205h
    sTXCANMessage_205h.ui32MsgID = 0x205; // either 11 or 29
    sTXCANMessage_205h.ui32Flags = MSG_OBJ_TX_INT_ENABLE;
    sTXCANMessage_205h.ui32MsgLen = 4;
    sTXCANMessage_205h.pucMsgData = txMsgData_205h;

    // INICJALIZACJA POCZATKOWYCH DANYCH W RAMCE 203h i 205h
    // init dana for 203h
    txMsgData_203h[0] = 0x1;
    txMsgData_203h[1] = 0x2;
    txMsgData_203h[2] = 0x3;
    txMsgData_203h[3] = 0x4;

    // init dana for 205h
    txMsgData_205h[0] = 0x1;
    txMsgData_205h[1] = 0x1;
    txMsgData_205h[2] = 0x1;
    txMsgData_205h[3] = 0x1;


    ////////////////////////////////////////////////////////////////////////
    //ODBIERANIE CAN inicjalizacja
    ///////////////////////////////////////////////////////////////////////

    // INICJALIZACJA (odbieranie) USTAWIEN CAN DLA RAMKI 103h
    //frame_103h
    // pMsgObject
    sRXCANMessage_103h.ui32MsgID = 0x103; // either 11 or 29
    //sRXCANMessage_103h.ui32MsgIDMask = 0;
    //sRXCANMessage_103h.ui32Flags = MSG_OBJ_RX_INT_ENABLE;
    sRXCANMessage_103h.ui32Flags = MSG_OBJ_USE_ID_FILTER;
    sRXCANMessage_103h.ui32MsgLen = 4;
    sRXCANMessage_103h.pucMsgData = rxMsgData_103h;


    CANEnable(CANA_BASE);

    for(;;)

    {

    // uaktualnianie wysylanych danych w ramce 203h do CAN
    // wpisane wartosci poczatkowe txMsgData_203h[4] sa zwiekszane o 1
    txMsgData_203h[0] += 0x01;
    txMsgData_203h[1] += 0x01;
    txMsgData_203h[2] += 0x01;
    txMsgData_203h[3] += 0x01;

    // uaktualnianie wysylanych danych w ramce 205h do CAN
    // wpisane wartosci poczatkowe txMsgData_205h[4] sa zwiekszane o 1 lub zmniejszane o 1
    txMsgData_205h[0] += 0x01;
    txMsgData_205h[1] -= 0x01;
    txMsgData_205h[2] += 0x01;
    txMsgData_205h[3] -= 0x01;
    // Opoznienie 0.5s
    DELAY_US(1000 * 500);

    //Wysylanie danych do CAN. Ramka 203h i 205h
    CANMessageSet(CANA_BASE,1, &sTXCANMessage_203h,MSG_OBJ_TYPE_TX);
    CANMessageSet(CANA_BASE,2, &sTXCANMessage_205h,MSG_OBJ_TYPE_TX);

    // Opoznienie 0.5s
    DELAY_US(1000 * 500);

    //Pobieranie danych z CAN. Ramka 103h
    CANMessageSet(CANA_BASE,3, &sRXCANMessage_103h, MSG_OBJ_TYPE_RX);
    // Opoznienie 0.5s
    DELAY_US(1000 * 500);


    //Odebranie danych z CAN.Ramka 103h. Odpowiednim przypisanie do zmiennym

    a=rxMsgData_103h[0];
    b=rxMsgData_103h[1];
    c=rxMsgData_103h[2];
    d=rxMsgData_103h[3];

    if(a==0x10)
    {
    //Wlaczenie LEDow
    GPIO_WritePin(RED_LED_GPIO, 0);
    GPIO_WritePin(BLUE_LED_GPIO, 0);
    DELAY_US(1000 * 500);
    }

    else
    {
    //Wylaczenie LEDow
    GPIO_WritePin(RED_LED_GPIO, 1);
    GPIO_WritePin(BLUE_LED_GPIO, 1);
    }
    DELAY_US(1000 * 500);

    }

    }

    //
    // End of File
    //

     

  • First and foremost, you need to ensure both nodes are configured for exactly the same bit-rate. This is extremely critical. Unless you ensure this there is no point in debugging further. I see that you are initializing the MCU to 250 kbps. What about the PC side? Are you sure it is configured for 250 kbps as well? Pay special attention to what Chris mentioned in an earlier post : "Additionally to what Hareesh mentioned, the controlSUITE examples are setup for the controlCARDs which have a different oscillator frequency. Make sure to add "_LAUNCHXL_F28377S" as a pre-defined symbol in your project. Details on this can be found in the "F2837xS-FRM-EX-UG", chapter 2, within the F2837xS v210 docs".

     

    Do this:

     

    1. Do not connect the nodes together. Transmission will be repeated forever due to lack of ACK, but that is OK.
    2. Let the PC side transmit first. Capture the bit-stream with an oscilloscope. Make sure the bit time corresponds to 250 kbps (4uS). And make sure it is indeed transmitting a STD MSGID of 103h. Please post the captured waveform in your next post.
    3. Repeat this for the Launchpad side. You can use the ControlSuite example " can_external_transmit" for this.
    4. Once you have ensured the bit-rates are the same, move on to the next step of the debug.

     

     

    In your code, you are both transmitting and receiving. For now, remove the transmit portion of the code and do only the receive operation.

     

    Also disable message filtering. Comment this line below.

    sRXCANMessage_103h.ui32Flags = MSG_OBJ_USE_ID_FILTER;

     

    Right now your code uses a fixed delay. Use the appropriate flag to determine data has been received. Otherwise it is hard to synchronize the communication.

  • Hi Hareesh

    There are the test
    1. Let the PC side transmit first. Capture the bit-stream with an oscilloscope. Make sure the bit time corresponds to 250 kbps (4uS). And make sure it is indeed transmitting a STD MSGID of 103h. Please post the captured waveform in your next post. (see attached scope files TEK0000,01,02,03). The frame 103h is transmitted every 4ms 
     

             2. Repeat this for the Launchpad side. The frame 203h is transmitted every 4ms . (see attached scope files TEK0004,05,06,07).
  • The only scope plots that are of relevance are the ones that show the bit time to be 4 uS. Why are the wave forms so noisy?

    Now, looking at the scope plots, there is no way to ascertain the MSGID. I presume the CAN-bus analyzer software on the PC has a GUI where you can verify that the correct MSGID is being transmitted.

    Please go thru my previous post carefully (disable filtering, disable transmission on the MCU side, Do not use a fixed delay for reception etc) and implement those ideas.

  • Hello,
    Please let us know if this issue has been resolved.
  • Any updates on this issue?

  • Hi,

    I am sorry for my late respons. My project has been closed. 

    So the problem with the Rx CAN at the moment  I have to stop.

    It will be time to continue it.

    Best regards

     

  • OK. Please close the post and re-open if/when needed.

  • Hi,
    I can't find the place where I can close the post
  • Hello,

    I have closed the post. Again, if you need to open back up just reply to this thread.

    Best Regards,
    Adam Dunhoft