CAN problem

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

CAN problem

1,628 Views
Nadia
Contributor III

Good afternoon, I am using the MCU LPC54628 from the test board. I am using the example lpcxpresso 54628_mcan_loopback. With the help of a breadboard I installed the MPC2551 transceiver, to take the signals from my MCU, TX and RX, and get CANL and CANH, but it doesn't work, does anyone know why? the program runs normally and doesn't give me failures.

Regards

0 Kudos
16 Replies

1,624 Views
frank_m
Senior Contributor III

For the test mode, you don't need a CAN transceiver.

Check the user manual (UM10912), section 35.14.1.7, and perhaps the CAN peripheral chapter (35) in general.

And check with the description of your SDK example if it goes for internal or external loop back mode.

1,622 Views
Nadia
Contributor III

@frank_m I know, but I want to see the CANH and CANL signals, because I need it to send it abroad.

0 Kudos

1,620 Views
frank_m
Senior Contributor III

As said, I don't know the SDK example, but I think you can modify it to use external loop-back (i.e. Tx and Rx physically linked externally).

Don't you have an experienced mentor near you, who can help you ?

You seem a bit overwhelmed at the moment, and fora like this take quite a lot of time, and don't guarantee answers. Or correct answers ...

0 Kudos

1,616 Views
Nadia
Contributor III

No, it's just that this is the first time I've used it, I think it's externally configured.

 

0 Kudos

1,603 Views
diego_charles
NXP TechSupport
NXP TechSupport

Hi Nadia!

In this case the loopback example of the LPC546xx will work regardless of the RX and TX pins, that may explain the reason why you are able to see that it works without any signals being generated.

diego_charles_0-1622239681066.png

Using the loopback  functionality ,you would only be able to monitor the output of the TX pin, the RX pin is disregarded.

So, if you want to generate the pair of RX and TX signals you may want to test with our MCAN_interrupt example. But here you will need  two boards. 

Let me know if I could help you further.

Diego

 

0 Kudos

1,588 Views
Nadia
Contributor III

@diego_charlesyes  please.

OK, but then I can't generate a CAN signal itself, i.e. using the MCP 2551 to obtain from TX the CANH and CANL ?

 

0 Kudos

1,584 Views
frank_m
Senior Contributor III

When using external loop back mode, an attached driver would still generate a proper CAN bus signal. You cannot use a device in loop back mode on a real CAN bus, though.

The loop back mode is useful for device-internal testing only. You cannot validate the correct baudrate, sample timing, correct wiring, and termination with this mode.

0 Kudos

1,582 Views
Nadia
Contributor III

OK, so would you know how I could do it?

0 Kudos

1,573 Views
frank_m
Senior Contributor III

Not sure what you mean, but even with external loop back mode, you could see the CANH / CANL signals on a transceiver attached to Tx. You cannot receive CAN messages from other nodes in loop back mode, though.

To get a CAN environment running from ground up, I would suggest two boards (preferably of the same type), and the following steps:

1. get the loop back example running, perhaps adapt it for external mode and observe the bus signals

2. Get a proper CAN example running (e.g. the suggested interrupt example) on both boards, and connect them directly (Tx / Rx / GND directly, without transceiver).

3. Add the transceivers to both nodes.

1,562 Views
Nadia
Contributor III

@frank_m Well, it doesn't work for me.
I'm using the MCP2551 to send data and I'm trying to read CANL and CANH and it's not working.

0 Kudos

1,559 Views
frank_m
Senior Contributor III

Do you see the Tx signal at the Tx pin ?

And at the MCP2552 input pin ?

And the transceiver is a 5V device, not 3.3V.

0 Kudos

1,536 Views
Nadia
Contributor III

@frank_m 

Yes, I got it working, a hardware problem, thanks.

Is there a way to verify that the plot has been sent correctly and that the master CAN has understood it?

 

Thank you very much.

Best regards

1,531 Views
frank_m
Senior Contributor III

You probably mean the message.

There is an acknowledge bit somewhere in the protocol. If sending fails, you should see the Tx error counter (a register in the CAN peripheral) see going up. Usually by 8 counts per message. Id not everything was fine...

CAN has no master/slave architecture, it is strictly message-based. The message ID determines the priority. There are several decent CAN tutorials you could check out.

BTW, pure CAN is rarely used nowadays. Most application use higher-level protocols like CANopen or J1939, with plenty of commercially available devices. My company's ECUs support CANopen.

 

1,528 Views
Nadia
Contributor III

Thank you very much for your quick response.
I need to use pure CAN, I will watch some tutorial if.

If I have not misunderstood you, it is impossible to know from the MCU that sends the message if it was all correct right?

Thank you very much again.
Best regards.

0 Kudos

1,509 Views
diego_charles
NXP TechSupport
NXP TechSupport

Hi @Nadia 

Complementing Frank's comments regarding the  TX  error fail. There are TX and RX error counters that every can controller has. This FAQ is good giving a mini overview of them   https://community.nxp.com/t5/LPC-FAQs/How-do-the-error-counters-work/m-p/590735 

On every failed receive of a frame the receive counter is increased and on every successful receive it is decreased.

On every failed transmit of a frame the transmit counter is increased and on every successful
transmit it is decreased.

I am not complete sure what do you mean with "all was correct" , but According to the BOSCH's CAN  specification there are 5 kinds of errors, see  http://esd.cs.ucr.edu/webres/can20.pdf#page=25  that are divided at message level and bit level. "Those are the errors that a transmitter and a receiver will check depending on the situation.

 

I hope it could help

Diego.

0 Kudos

1,467 Views
frank_m
Senior Contributor III

I avoided going into much CAN details here, there would be too much to cover here potentially ...

But to observe CAN bus events, you can debug your MCU, and check for CAN peripheral flags and events. Consult the MCU user manual for details.

And secondly, I would highly recommend some analysing/monitoring equipment. The Vector equipment is good, but a bit pricey. There exist cheaper alternatives that can do the job in many circumstances.

My company uses a lot of PEAK stuff (www.peak-system.com), besides of Vector tools.

0 Kudos