how to fix CAN connection errors?

Mohamed Ahmed picture Mohamed Ahmed · Sep 10, 2018 · Viewed 9.5k times · Source

i'm newbie to the field of automotive, i'm trying to make a connection with can bus between CAN box and aurix board and monitor this connection using CANoe software.

i'm only trying to send a simple message one time from the kit over the can bus as a start just to test the connection and make sure it works before i proceed with the rest of the application.

but all i receive from the kit on CANoe is errors like Form errors, stuff error, CRC error, CAN overload frame.

i checked the pins of the can on the board multiple times to make sure they are correct, also tried to change the CAN channel used on the CAN box, even checked the wires and every thing seems like connected correctly.

and the software i'm using is only a demo that i found inside TASKING compiler demos in the files related the the kit i'm using so i can assume it's not wrong. the steps i followed to get it this demo to compile are simple

  1. use the software platform builder inside TASKING IDE to attach the files related to the kit to the project.
  2. include the CAN driver file in it "IfxMultican_Can.h"
  3. then i copied and pasted the code inside the documentation within that header file into my project.

i did every thing i could think of to get this to work but still same errors, so it's either the connections are wrong some how or the driver code provided with TASKING IDE contains errors, there is nothing else in the system.

the code i'm using for the project is

#include <stdio.h>
#include "SoftwarePlatform/illd_tc29xb/src/ifx/TC29xB/Multican/Can/IfxMultican_Can.h"

// CAN handle
IfxMultican_Can can;

// Nodes handles
IfxMultican_Can_Node canSrcNode;
IfxMultican_Can_Node canDstNode;

// Message Object handles
IfxMultican_Can_MsgObj canSrcMsgObj;
IfxMultican_Can_MsgObj canDstMsgObj;

const unsigned id = 0x100;

int main(){
    // create configuration
    IfxMultican_Can_Config canConfig;
    IfxMultican_Can_initModuleConfig(&canConfig, &MODULE_CAN);

    //initialize module
    //IfxMultican_Can can; // defined globally
    IfxMultican_Can_initModule(&can, &canConfig);

    // create CAN node config
    IfxMultican_Can_NodeConfig canNodeConfig;
    IfxMultican_Can_Node_initConfig(&canNodeConfig, &can);

    canNodeConfig.baudrate = 1000000; // 1 MBaud

    // Source Node
    // IfxMultican_Can_Node canSrcNode; // defined globally
    {
        canNodeConfig.nodeId = IfxMultican_NodeId_0;
        canNodeConfig.rxPin = &IfxMultican_RXD0B_P20_7_IN;
        canNodeConfig.rxPinMode = IfxPort_InputMode_pullUp;
        canNodeConfig.txPin = &IfxMultican_TXD0_P20_8_OUT;
        canNodeConfig.txPinMode = IfxPort_OutputMode_pushPull;

        // initialize the node
        IfxMultican_Can_Node_init(&canSrcNode, &canNodeConfig);
    }

    // Destination Node
    // IfxMultican_Can_Node canDstNode; // defined globally
    {
        canNodeConfig.nodeId = IfxMultican_NodeId_1;
        canNodeConfig.rxPin = &IfxMultican_RXD1B_P14_1_IN;
        canNodeConfig.rxPinMode = IfxPort_InputMode_pullUp;
        canNodeConfig.txPin = &IfxMultican_TXD1_P14_0_OUT;
        canNodeConfig.txPinMode = IfxPort_OutputMode_pushPull;

        // initialize the node
        IfxMultican_Can_Node_init(&canDstNode, &canNodeConfig);
    }

    // IfxMultican_Can_MsgObj canSrcMsgObj; // defined globally
    {
        // create message object config
        IfxMultican_Can_MsgObjConfig canMsgObjConfig;
        IfxMultican_Can_MsgObj_initConfig(&canMsgObjConfig, &canSrcNode);

        // assigned message object:
        canMsgObjConfig.msgObjId = 0;

        canMsgObjConfig.messageId = id; // 'id' is defined globally
        canMsgObjConfig.acceptanceMask = 0x7FFFFFFFUL;
        canMsgObjConfig.frame = IfxMultican_Frame_transmit;
        canMsgObjConfig.control.messageLen = IfxMultican_DataLengthCode_8;
        canMsgObjConfig.control.extendedFrame = FALSE;
        canMsgObjConfig.control.matchingId = TRUE;

        // initialize message object
        IfxMultican_Can_MsgObj_init(&canSrcMsgObj, &canMsgObjConfig);
    }

    // IfxMultican_Can_MsgObj canDstMsgObj; // defined globally
    {
        // create message object config
        IfxMultican_Can_MsgObjConfig canMsgObjConfig;
        IfxMultican_Can_MsgObj_initConfig(&canMsgObjConfig, &canDstNode);

        // assigned message object:
        canMsgObjConfig.msgObjId = 2;

        canMsgObjConfig.messageId = id;
        canMsgObjConfig.acceptanceMask = 0x7FFFFFFFUL;
        canMsgObjConfig.frame = IfxMultican_Frame_receive;
        canMsgObjConfig.control.messageLen = IfxMultican_DataLengthCode_8;
        canMsgObjConfig.control.extendedFrame = FALSE;
        canMsgObjConfig.control.matchingId = TRUE;


        // initialize message object
        IfxMultican_Can_MsgObj_init(&canDstMsgObj, &canMsgObjConfig);
    }

    const unsigned dataLow = 0xC0CAC01A;
    const unsigned dataHigh = 0xBA5EBA11;

    // Initialize the message structure
    IfxMultican_Message txMsg;
    IfxMultican_Message_init(&txMsg, id, dataLow, dataHigh, IfxMultican_DataLengthCode_8);

    // Transmit Data
    while( IfxMultican_Can_MsgObj_sendMessage(&canSrcMsgObj, &txMsg) == IfxMultican_Status_notSentBusy );

    return 0;
}

some examples of the errors i get in CANoe

   Time            Chn     ID   Name   Event Type   Dir     DLC   Data                                                 
   [-] 18.909137   CAN 1               CAN Error    RxErr         ECC: 100000011xxxxx, Form Error, Bit Position = 12   
   |  ECC          100000011xxxxx            
   |  Code         Form Error                
   |  Position     12                        
   |  ID           0010010011001b (499)      
   |  DLC          9                         
   |  Data 00-07   00 00 00 00 00 00 00 00   

another example

   Time            Chn     ID   Name   Event Type   Dir     DLC   Data                                                
   [-] 18.907080   CAN 1               CAN Error    RxErr         ECC: 100001001xxxxx, CRC Error, Bit Position = 36   
   |  ECC          100001001xxxxx            
   |  Code         CRC Error                 
   |  Position     36                        
   |  ID           0010010011001b (499)      
   |  DLC          9                         
   |  Data 00-07   00 00 00 00 00 00 00 00   

i also must point that despite i only send the message once, i keep receiving a non-ending sequence of those errors until i stop the simulation.

is there any way i can use to better understand how to fix those errors? any information about the kit pins numbering or the correct connection for can would be very helpful. i also must point that i'm only using the driver for the can abstractly from how it works, i only understand the CAN as bus on which i'll throw a message and receive it from the other end using some functions i don't know how it actually works and the time i have is quite limit and doesn't allow me to learn that much.

board used : KIT_AURIX_TC297_TFT , CAN box : VN6510A

Answer

Vin&#237;cius Oliveira picture Vinícius Oliveira · Sep 24, 2018

You need to change your baudrate in CANOe from 500.0 to 1000.0 Kbps (as configured in infineon iLLD canNodeConfig.baudrate = 1000000; // 1 MBaud)

Also, make sure you have 120 Ohm resistor between CANH and CANL.

Try to see your output from microcontroler (CAN TX/CAN RX) in oscilloscope or logic analyser, also the output from your CAN transceiver, since you are using TFT board you already have the transceiver resistor.