Receiving CAN message (car vs. CAN King KVASER)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Receiving CAN message (car vs. CAN King KVASER)

1,885 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by teslabox on Thu Jan 12 07:35:05 MST 2012
Hello everyone,

I try to receive a CAN message @ID=230(dec) from my car but it doesn't work at all. But when I send a message (test message) from KVASER CAN King device @ID=230(dec) my LPCXpresso LPC1C24 work properly and toggle the LED when the message is received from it.
I make the same alghoritm on my LPC1768 evaluation borad and the efect is the same as before. I have no idea why it behaves this way.
What can cause this that on my desk everything work great but in the car is doesn't work?
0 Kudos
15 Replies

1,341 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by teslabox on Wed Feb 22 02:20:57 MST 2012
Hey,

I solved the hardware problem. The reason was to solder out terminator resistors as Zero said before – thanks a lot for You!
The effect was immediately. For CAN King KVASER it is necessary needed to solder in those terminator resistors but in the car obviously it is inappropriate!


I have other problem now. I have a code as follows:
#include "LPC17xx.h"
#include <cr_section_macros.h>
#include <NXP/crp.h>

#include "cantxbasic.h"            // my libary
#include "uartbasic.h"            // my libary

// main loop
int main (void)
{
    UART1_Init ();            // initalize the UART1 pins
    UART1_Bitrate (115200);        // set required UART1 bitrate

    CAN2_Init ();            // initalize the CAN2 pins
    CAN2_Bitrate (125000);        // set required CAN2 bitrate
    NVIC_EnableIRQ (CAN_IRQn);    // enable global CAN interrupts
    LPC_CAN2->IER |= (1<<0);    // enable the Receiver Interrupt, if Receive Buffer Status is 'full' CAN controller requests the respective interrupt

    for (;;) {}            // do nothing in main loop

    return (0);
}

uint8_t temp = 0;    // variable for CAN interrupt loop usage     

// CAN interrupt loop
void CAN_IRQHandler (void)
{
    if (LPC_CAN2->ICR & (1<<0))        // Receive Interrupt
    {
        if (LPC_CAN2->RID == 0xB6)    // if ID of received message is 0xB6, then do if condition
        {
            temp = (((LPC_CAN2->RDB) & (0x00FF0000)) >> 16);    // read byte number 6 (B0, B1,... , B7) and shit it to the right side (on B0 place)
            LPC_UART1->THR = temp;                    // send B6 value thru the UART1
            LPC_CAN2->CMR = 0x01 << 2;                // ready for next received frame clear the RBS bit in the Status Register 
        }
    }
}


If I send CAN message with ID 0xB6 as first message then I received from UART1 expected value (as was sent to the CAN) - it is OK. But if I send CAN message with any other ID (e.g. 0xB7 or 0x123)  something is blocked and I don't receive any data from UART1. Worst: even if I send in next step CAN message ID with 0xB6 it is still blocked and only total reset can help.
0 Kudos

1,341 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by teslabox on Fri Feb 17 07:08:16 MST 2012
[B]Hello,[/B]


Quote: Zero
If your bus is already terminated, you have to reduce this termination (= solder out this 2 * 60 Ohm resistors)



Yes, it is already terminated because it is a CAN bus in a new brand car working at 125 kpbs.

Now I'm using an mbest board EM-LPC1700 with a LPC1768. I tried to comunicate this evalboard with CAN King KVASER and everything is work properly.

On the EM-LPC1700 evalboard there are two CAN channels. I only use the second one. I saw that there are two 51 Ohm terminator resistors [I](R40 and R41)[/I] as shown on the schematic[I] (look at the attachement: embest EM-LPC1700 Schematic.pdf  in ZIP file, page 5, DB9_COM J6, top left corner of the sheetpaper)[/I]. I soldered them out and it still doesn't work porperly in the car and CAN King KVASER shown a "FrameError".

Also when I connect it [I](without R40 and R41 resistors)[/I] to the CAN King KVASER then the "FrameError" occurs during when I send or receive a message from or to CAN King KVASER.

Now I made a socket from universal 2.54 mm Berg goldpins and I can connect or disconnect terminators[I] (two 100 Ohm resistors)[/I] very fast to check the differences. And if I only remove them from the socket I get "FrameError".
0 Kudos

1,341 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Mon Jan 16 07:53:53 MST 2012
Do you understand what I'm talking about?

KVASER has informed you, that they are not using termination resistors. They are trying to avoid problems with already terminated bus systems or low speed CAN like TJA1054. So you should think about your bus system (is it FTCAN?) and termination. To scope the signal would give you an impression what you are sitting in front of :rolleyes:

LPCXpresso11C24 is using a correct termination (120 Ohm) . If your bus is already terminated, you have to reduce this termination (= solder out this 2 * 60 Ohm resistors) :eek:
0 Kudos

1,341 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by teslabox on Mon Jan 16 07:36:02 MST 2012

Quote: Zero
The Kvaser Leaf devices do not have built-in termination.
You must ensure your CAN bus have appropriate termination, or the communication may be unreliable. 


Yes, OK, but KVASER isn't a problem. KVASER works good.
Problem is in the LPCXpresso LPC11C24 - it doesn't work properly.
0 Kudos

1,341 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Mon Jan 16 07:28:00 MST 2012

Quote: teslabox
Yes, I'm using KVASER Leaf Professional  HS hardware and it works really great - I have never any problem with it.



And did you read it's manual?


Quote:

3.6.3 CAN Bus Termination
The Kvaser Leaf devices do not have built-in termination.
You must ensure your CAN bus have appropriate termination, or the communication may be unreliable.

0 Kudos

1,341 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by teslabox on Mon Jan 16 07:20:24 MST 2012

Quote: OXO
OBD2 at 125kbits? Unlikely..

Try it at 500kbits, and you WILL need the Module ID to set the acceptance filter to receive the messages.



Ok, we didn't understand each other.
I used the OBD II interface in my previous project and it is finished.

In this problem I connect to the CAN bus directly behind the dashboard (not in the OBD connector). The are two CAN wires which trasmit a lot of data to dashboard computer and my goal is to read them and find interesting information.


Quote: Zero
Another unclear point is termination :eek:

Are you using KVASER hardware? If so it's possible that's there's no termination resistor (KVASER Leaf).



Yes, I'm using KVASER Leaf Professional  HS hardware and it works really great - I have never any problem with it.


Quote: Zero
Is your LPCXpresso11C24 still terminated with 120 Ohm, is your LPC1768 terminated?



So, it is done as it is shown here on the page 5:
http://ics.nxp.com/support/documents/microcontrollers/pdf/lpcxpresso.lpc11c24.schematic.pdf
0 Kudos

1,341 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Mon Jan 16 06:46:29 MST 2012
Another unclear point is termination :eek:

Are you using KVASER hardware? If so it's possible that's there's no termination resistor (KVASER Leaf).

Is your LPCXpresso11C24 still terminated with 120 Ohm, is your LPC1768 terminated?
0 Kudos

1,341 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by OXO on Mon Jan 16 04:50:02 MST 2012
OBD2 at 125kbits? Unlikely..

Try it at 500kbits, and you WILL need the Module ID to set the acceptance filter to receive the messages.
0 Kudos

1,341 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Mon Jan 16 02:48:30 MST 2012

Quote: teslabox
- Peugeot 407 (c.a. 2010 year)
- Peugeot Partner 2011 year



OMG, french cars :eek:

Did you scope the signals already? Are you sure we are talking about CAN and not about VAN?

http://en.wikipedia.org/wiki/Vehicle_Area_Network
0 Kudos

1,341 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by teslabox on Mon Jan 16 01:16:29 MST 2012

Quote: OXO
What car is it? How old?


The cars are:
- Peugeot 407 (c.a. 2010 year)
- Peugeot Partner 2011 year

Quote: OXO
Does it use 29 bit or 11 bit IDs..?


Both of them use 11-bit IDs.

Quote: OXO
What is the ECU ID?


I don't know. I don't need it now.

Quote: OXO
What bit rate are you using?


In both of them is bitrate 125 kbps.

Additional:
I use two twisted wires 1 meter long with diameter ca. 0.25 mm of each (10 mils).

What interesting?
I use the same LPCXpresso board (with LPC11C24) to connect to the OBD II interface in Peugeot Partner 2011 year and I transmit and receive CAN messages in service mode properly. So I don't know where is the reason of my problem.
0 Kudos

1,341 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by OXO on Fri Jan 13 14:11:15 MST 2012
What car is it? How old?

Does it use 29 bit or 11 bit IDs..? What is the ECU ID?

What bit rate are you using?

As Zero already asked, if you don't provide us any information, how do you expect us to help?
0 Kudos

1,341 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by teslabox on Fri Jan 13 07:37:04 MST 2012

Quote: Polux rsv
Is your car at least sending this message ???:D

Angelo



Yes, it is all the time :) - I chcecked it using CAN King device (by KVASER).
0 Kudos

1,341 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by OXO on Fri Jan 13 01:23:04 MST 2012
Post your code showing the acceptance filter setup.
0 Kudos

1,341 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Polux rsv on Fri Jan 13 00:56:53 MST 2012

Quote: teslabox

I try to receive a CAN message @ID=230(dec) .....



Is your car at least sending this message ???:D

Angelo
0 Kudos

1,341 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Thu Jan 12 08:07:15 MST 2012
Wrong wires, wrong format, wrong speed, wrong day or wrong weather :eek:

So scope the signal to ensure that your settings are correct :rolleyes:

Then use your 1768 with can transceiver get scope your CAN_RX signal and check that :rolleyes:

Setup you code to receive all IDs and check if it's receiving something :confused:
0 Kudos