This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Need example to get CAN running

I have problems to get the CAN controller on my Infineon XC886 CM running. Have someone example code for sending a CAN message via CAN node 0 (CAN RXD Port 1_6, CAN TXD Port 1_7)? I have tryed to use Dave-generated code with the following code in my main-function:

un_32bit canTestObject;

canTestObject.ubDB[0] = 0x77;
canTestObject.ubDB[1] = 0x76;
canTestObject.ubDB[2] = 0x75;
canTestObject.ubDB[3] = 0x74;

CAN_vLoadData(0x00, &canTestObject.ulVal);
CAN_vSetMSGVAL(0x00);
CAN_vTransmit(0x00);

But it only works in the software-simulator (in der Peripherals->MultiCAN->CAN Communication 0 window the sended messages appear) but not on my self-made board (nothing to see with oscilliscope on the MCU-Pins 1_6 and 1_7).

  • "But it only works in the software-simulator"

    So why do you think another example will help?

    If it works in the simulator, then the logic must be basically correct - the problem must be down to some hardware-dependency; eg,

    * The hardware design is flawed;
    * The hardware design is good, but you've built it wrong;
    * The hardware design is good, you've built it right, but some component(s) is/are faulty;
    * The hardware's all good, but your software is not correctly configured for it;
    * The hardware's all good, but your software has some timing issue or other hardware dependency/interaction that doesn't show up in simulation;
    etc, etc,...

    You need to locate the problem first!

  • Actually I dont know what is the problem, maybe its the hardware. But I have build two boards which are based on the schematic of the Keil evaluation boards. All other functions on both boards working fine, only CAN does not. So I thought the problem is the software. I will check the hardware again to see what is maybe wrong.

    Thank you for your comment!

  • Something I forgot: If I had a working software and it does not work on my hardware, so I can assume that the problem is the hardware.

  • "I had a working software and it does not work on my hardware, so I can assume that the problem is the hardware"

    Not necessarily.

    For example, imagine that you simulated something that uses the UART - the simulation works fine, but it doesn't work on your hardware.
    This could be because your software loads an incorrect value for the baud rate divisor - that wouldn't affect the simulation, but would mean that the baud rate would be wrong on the real hardware and, therefore, your serial comms would not work.

    That would be the penultimate one in the list I gave earlier:

    "* The hardware's all good, but your software is not correctly configured for it"

  • Define does not work?
    What is it talking to? ( It must be connected to a functing node to work)
    Are the lines terminated?
    Are the buad rates and time set the same?

  • Another one for the list of reasons why something might work in simulation, but not in real life:

    * You have misunderstood the way some external device works, so your software is based on this misunderstanding and your simulation is based on the same misunderstanding - hence they work together in simulation, but not with the real behaviour of a real device in real life!