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.

C2000 CANBUS BIT ERROR FLAG PROBLEM

Other Parts Discussed in Thread: TMS320F28054F

Hi Dear Masters,

I try to get message canbus line with TMS320F28054F

I use as a reference project "Example_2805xECanBack2Back"

I am sure, I can transmit canbus message successfully.  (I see message which i send via another custom design board)

But i cannot receive message with same canbus baud rate  

I look at "Error and Status Register (CANES) Field"

RM (Receive Mode) bit generally 1

BE (Bit Error Flag) bit always 1 

When BE bit is 1, CANBUS reference guide say that :  "The received bit does not match the transmitted bit outside of the arbitration field"

I send message with std id = 1  ( via another custom design board )


I set my mailbox configs :

ECanaMboxes.MBOX16.MSGID.all = 0x40000;  

ECanaRegs.CANMD.bit.MD16 = 1;

ECanaRegs.CANME.bit.ME16 = 1;

(for my initializing and receive routine see : TIquestion.rarattachment)

but i cannot receive message..

I am waiting your help,
sorry for my bad English..
thanks.

Best regards from Türkiye.

  • Mehmet,

                How many nodes do you have in your network? Let us work with the assumption that it is two. If the transmission (and the corresponding reception) works in one direction, it is reasonable to assume that there is no hardware issue in your setup and there is no reason why the transmission/reception will not work from the other side. Do you mind posting your CAN circuit? Do you have a CAN transceiver (and a 120-ohm terminator) on both ends of the network?

     

    The transceiver also loops back the transmitted data into the CANRX pin. The CAN module always checks if the received bit matches the transmitted bit (outside of the arbitration and ACK field, of course). If a transceiver is missing, it could flag a bit error. (This is one of the reasons for bit error, not the only reason)

     

     

  • Dear Hareesh J,
    thanks for your response.

    "How many nodes do you have in your network?"   I have 2 nodes

    "Do you mind posting your CAN circuit? "    I try to draw my can circuit amateurishly...  
    ( i send canbus message with node 2 successfully , and i receive message with node1 successfully with this canbus circuit )
    ( Node2 use C2000, Node1 use another MCU)

    "Do you have a CAN transceiver (and a 120-ohm terminator) on both ends of the network?" Yes. I have.

    "The transceiver also loops back the transmitted data into the CANRX pin. The CAN module always checks if the received bit matches the transmitted bit (outside of the arbitration and ACK field, of course). If a transceiver is missing, it could flag a bit error. "

    I did not understand completely above sentences.

    Node1 is continuously sending canbus message with Standard Id=1, DLC=8, 500 kbit/s. 
    (I am sure i can send. i observe with oscilloscope and also i use node1 in another canbus project successfully. please believe me :) )

    I want to receive message with Node2.. 
    Because of i just want receive message, i set only receive configurations (for mailbox16).

    ECanaShadow.CANTIOC.bit.TXFUNC = 0;
    ECanaShadow.CANRIOC.bit.RXFUNC = 1;

    500 kbit/s 

    Choose Standard Id=1    : ECanaMboxes.MBOX16.MSGID.all = 0x40000;
    Mailbox direction receive : ECanaRegs.CANMD.bit.MD16 = 1;
    Enable mailbox               : ECanaRegs.CANME.bit.ME16 = 1;


    Because of i just want receive message, i did not set any transmit configurations .

    Is this conditions cause bit error flag?  
    You said that
    "The CAN module always checks if the received bit matches the transmitted bit (outside of the arbitration and ACK field, of course)"

    i just want to receive message with Node2, i set receive configurations in node2, do i have to set transmit configurations in node2. 

    Thanks,


  • Mehmet,

    The problem is with the following line:

    ECanaShadow.CANTIOC.bit.TXFUNC = 0;

    Even though you are not "transmitting" anything, the receiving node still needs to ACKnowldege the frame it received. This is automatically taken care of by the CAN module. There is no need for you to do anything specific. With the above statement, you are blocking the ACK signal from going out.

    One more thing:

    You are not using 32-bit R/W.

    ECanaRegs.CANMD.bit.MD16 = 1;

    ECanaRegs.CANME.bit.ME16 = 1;

    For operations like above, you must use 32-bit R/W using shadow registers.

  • Thank you Mr. Hareesh J.  I did what you said and bit error problem solved

    There is not any problem in Error and Status Register (CANES).

    But unfortunately, still i cannot receive any message... 

    My main code is :

    void main(void)
    {
    
    struct ECAN_REGS ECanaShadow;
    
    InitSysCtrl();
    
    InitGpio();
    
    InitECanGpio();
    
    DINT;
    
    InitPieCtrl();
    
    IER = 0x0000;
    IFR = 0x0000;
    
    InitPieVectTable();
    
    InitECana(); // Initialize eCAN-A module
    
    ECanaMboxes.MBOX16.MSGID.all = 0x40000;  //for standart id=1
    
    // Configure Mailbox 16 Rx
    EALLOW;
    ECanaShadow.CANMD.all = ECanaRegs.CANMD.all;
    ECanaShadow.CANMD.bit.MD16 = 1;
    ECanaRegs.CANMD.all = ECanaShadow.CANMD.all;
    EDIS;
    
    // Enable Mailbox 16
    EALLOW;
    ECanaShadow.CANME.all = ECanaRegs.CANME.all;
    ECanaShadow.CANME.bit.ME16 = 1;
    ECanaRegs.CANME.all = ECanaShadow.CANME.all;
    EDIS;
    
    
    for(;
    {
    while(ECanaRegs.CANRMP.bit.RMP16==0) {}  	   // Wait for all RMPn to be set..
    
    ECanaRegs.CANRMP.bit.RMP16=1;
    }
    }
    

    My initializing code is :

    void InitECan(void)
    {
       InitECana();
    }
    
    void InitECana(void)        
    {
    struct ECAN_REGS ECanaShadow;
    
        EALLOW;     // EALLOW enables access to protected bits
    
        ECanaShadow.CANTIOC.all = ECanaRegs.CANTIOC.all;
        ECanaShadow.CANTIOC.bit.TXFUNC = 1;
        ECanaRegs.CANTIOC.all = ECanaShadow.CANTIOC.all;
    
        ECanaShadow.CANRIOC.all = ECanaRegs.CANRIOC.all;
        ECanaShadow.CANRIOC.bit.RXFUNC = 1;
        ECanaRegs.CANRIOC.all = ECanaShadow.CANRIOC.all;
    
    /* Configure eCAN for HECC mode - (reqd to access mailboxes 16 thru 31) */
        ECanaShadow.CANMC.all = ECanaRegs.CANMC.all;
        ECanaShadow.CANMC.bit.SCB = 1;
        ECanaRegs.CANMC.all = ECanaShadow.CANMC.all;
    
    /* Initialize all bits of 'Message Control Register' to zero */
        ECanaMboxes.MBOX0.MSGCTRL.all = 0x00000000;
        ECanaMboxes.MBOX1.MSGCTRL.all = 0x00000000;
        ECanaMboxes.MBOX2.MSGCTRL.all = 0x00000000;
        ECanaMboxes.MBOX3.MSGCTRL.all = 0x00000000;
        ECanaMboxes.MBOX4.MSGCTRL.all = 0x00000000;
        ECanaMboxes.MBOX5.MSGCTRL.all = 0x00000000;
        ECanaMboxes.MBOX6.MSGCTRL.all = 0x00000000;
        ECanaMboxes.MBOX7.MSGCTRL.all = 0x00000000;
        ECanaMboxes.MBOX8.MSGCTRL.all = 0x00000000;
        ECanaMboxes.MBOX9.MSGCTRL.all = 0x00000000;
        ECanaMboxes.MBOX10.MSGCTRL.all = 0x00000000;
        ECanaMboxes.MBOX11.MSGCTRL.all = 0x00000000;
        ECanaMboxes.MBOX12.MSGCTRL.all = 0x00000000;
        ECanaMboxes.MBOX13.MSGCTRL.all = 0x00000000;
        ECanaMboxes.MBOX14.MSGCTRL.all = 0x00000000;
        ECanaMboxes.MBOX15.MSGCTRL.all = 0x00000000;
        ECanaMboxes.MBOX16.MSGCTRL.all = 0x00000000;
        ECanaMboxes.MBOX17.MSGCTRL.all = 0x00000000;
        ECanaMboxes.MBOX18.MSGCTRL.all = 0x00000000;
        ECanaMboxes.MBOX19.MSGCTRL.all = 0x00000000;
        ECanaMboxes.MBOX20.MSGCTRL.all = 0x00000000;
        ECanaMboxes.MBOX21.MSGCTRL.all = 0x00000000;
        ECanaMboxes.MBOX22.MSGCTRL.all = 0x00000000;
        ECanaMboxes.MBOX23.MSGCTRL.all = 0x00000000;
        ECanaMboxes.MBOX24.MSGCTRL.all = 0x00000000;
        ECanaMboxes.MBOX25.MSGCTRL.all = 0x00000000;
        ECanaMboxes.MBOX26.MSGCTRL.all = 0x00000000;
        ECanaMboxes.MBOX27.MSGCTRL.all = 0x00000000;
        ECanaMboxes.MBOX28.MSGCTRL.all = 0x00000000;
        ECanaMboxes.MBOX29.MSGCTRL.all = 0x00000000;
        ECanaMboxes.MBOX30.MSGCTRL.all = 0x00000000;
        ECanaMboxes.MBOX31.MSGCTRL.all = 0x00000000;
    
    // TAn, RMPn, GIFn bits are all zero upon reset and are cleared again as a matter of precaution.
    
        ECanaRegs.CANTA.all = 0xFFFFFFFF;   /* Clear all TAn bits */
        ECanaRegs.CANRMP.all = 0xFFFFFFFF;  /* Clear all RMPn bits */
    
        ECanaRegs.CANGIF0.all = 0xFFFFFFFF; /* Clear all __interrupt flag bits */
        ECanaRegs.CANGIF1.all = 0xFFFFFFFF;
    
    /* Configure bit timing parameters for eCANA*/
    
        ECanaShadow.CANMC.all = ECanaRegs.CANMC.all;
        ECanaShadow.CANMC.bit.CCR = 1 ;            // Set CCR = 1
        ECanaRegs.CANMC.all = ECanaShadow.CANMC.all;
    
        // Wait until the CPU has been granted permission to change the configuration registers
        do {ECanaShadow.CANES.all = ECanaRegs.CANES.all;} while(ECanaShadow.CANES.bit.CCE != 1 ;       // Wait for CCE bit to be set..
    
        ECanaShadow.CANBTC.all = 0;
        // for 500kbit/s
        ECanaShadow.CANBTC.bit.BRPREG = 5;
        ECanaShadow.CANBTC.bit.TSEG2REG = 1;
        ECanaShadow.CANBTC.bit.TSEG1REG = 6;
    
        ECanaShadow.CANBTC.bit.SAM = 1;
        ECanaRegs.CANBTC.all = ECanaShadow.CANBTC.all;
    
        ECanaShadow.CANMC.all = ECanaRegs.CANMC.all;
        ECanaShadow.CANMC.bit.CCR = 0 ;            // Set CCR = 0
        ECanaRegs.CANMC.all = ECanaShadow.CANMC.all;
    
        // Wait until the CPU no longer has permission to change the configuration registers
        do { ECanaShadow.CANES.all = ECanaRegs.CANES.all;} while(ECanaShadow.CANES.bit.CCE != 0);       // Wait for CCE bit to be  cleared..
    
    /* Disable all Mailboxes  */
        ECanaRegs.CANME.all = 0;        // Required before writing the MSGIDs
    
        EDIS;
    }
    
    
    void InitECanGpio(void)
    {
       InitECanaGpio();
    }
    
    void InitECanaGpio(void)
    {
       EALLOW;
    
        GpioCtrlRegs.GPAPUD.bit.GPIO30 = 0;     // Enable pull-up for GPIO30 (CANRXA)
        GpioCtrlRegs.GPAPUD.bit.GPIO31 = 0;     // Enable pull-up for GPIO31 (CANTXA)
    
        GpioCtrlRegs.GPAQSEL2.bit.GPIO30 = 3;   // Asynch qual for GPIO30 (CANRXA)
    
        GpioCtrlRegs.GPAMUX2.bit.GPIO30 = 1;    // Configure GPIO30 for CANRXA operation
        GpioCtrlRegs.GPAMUX2.bit.GPIO31 = 1;    // Configure GPIO31 for CANTXA operation
    
        EDIS;
    }

    as i said before:  I send message to Node2 frorm Node1 with std id =1 

    So i only set my Node2 mailbox16's std id=1  ( ECanaMboxes.MBOX16.MSGID.all = 0x40000; ) and i predict that i can receive message from Node1 like this.  ( i did not do anything about acceptance mask ) 

    but i cannot receive.

    Could you help me about this problem please ?

    Thanks. 

  • Mr. Hareesh J
    i need your help.
    Please
  • Mehmet,

    In the line where you check the RMP bit, you must employ 32-bit reads by using the shadow register:

    while(ECanaRegs.CANRMP.bit.RMP16==0) {}        // Wait for all RMPn to be set..

    Take a look at how we check for the value of the CCE bit in the init code.

    Also, are you sure the message from the transmitting node got out? 

  • Mehmet,

    As mentioned in my previous post, you always need to employ 32-bit R/W while accessing the CAN registers. One method to check the RMP16 bit would be:

    do

        {

          ECanaShadow.CANRMP.all = ECanaRegs.CANRMP.all;

        } while(ECanaShadow.CANRMP.bit.RMP16 == 0 );       // Wait for RMP16 to be set....

     

    Please ensure the message  indeed gets put out on the bus.

  • Thank you for your answers.. I will try, and i will write result..
    ( I sure that i can send message, i watched bus with osciloskop. And i saw messages. )

    Thanks again.