MPC5668g sample CAN driver code.

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

MPC5668g sample CAN driver code.

Jump to solution
4,525 Views
sukruthrameshba
Contributor III

I have downloaded sample CAN driver code for MPC5668G and flashed on to the microcontroller.

But i am getting "stuff error" and "rx error". Can any one help me out regarding this issue?

Labels (1)
1 Solution
3,890 Views
PetrS
NXP TechSupport
NXP TechSupport

I tested this example on the EVB to do a communication between CAN_F and CAN_B and it works. See attached file.

You can try different baud rates. If you will have troubles still, check CAN signals with scope.

BR, Petr

View solution in original post

11 Replies
3,890 Views
sukruthrameshba
Contributor III

We found the issue which was in the voltage supplied to the transceiver. And we fixed this by supplying necessary voltage. Now everything is working fine.Thanks for your continuous support.

0 Kudos
3,890 Views
sukruthrameshba
Contributor III

I checked in the scope too, By tapping TXD and RXD of CAN transceiver.

In this case i saw that , In RXD there is always 1 bit missing, so there after is starts throwing an error frame.

So can you help me out in tracing out where the exact problem is?

0 Kudos
3,890 Views
PetrS
NXP TechSupport
NXP TechSupport

can you share scope screens?

3,890 Views
sukruthrameshba
Contributor III

Please find the attached scope pics, when I am sending CAN frame from the microcontroller.

Tapped signals are as follows

1.Rxd

2.Txd.

3.CANH

4.CANL

0 Kudos
3,890 Views
PetrS
NXP TechSupport
NXP TechSupport

Seems a scope trigger is not synchronized, and you just stopped the scope. I think you are getting this kind of signal, which says error frames are generated and you periodicaly entering and leaving bus off state. It is because permanent error on the bus.

pastedImage_0.png

   pastedImage_6.png

Try to unconnect can module from the transceiver and just connect TX RX pins together, assuming internal pull ups are used on RX pin. Then you should get following on TX line. Message must be transmitted still. This is because it is not acknowledged from other node.

pastedImage_4.png

  pastedImage_5.png

If you see a correct message, then there is some issue with transceiver or a bus. Try to use lower baud rate.

3,891 Views
PetrS
NXP TechSupport
NXP TechSupport

I tested this example on the EVB to do a communication between CAN_F and CAN_B and it works. See attached file.

You can try different baud rates. If you will have troubles still, check CAN signals with scope.

BR, Petr

3,890 Views
sukruthrameshba
Contributor III

Dear Petr,

Thanks for your comments,

To provide little more information, we are trying to use CAN_F and we changed the code accordingly by referring the manual.. I am attaching the modified code as below. In the main case 0 for transmission is happening and waiting in "Poll CAN Tx flag to track successful transmission"

Kindly let us know, whether we need to change anything else.

Code2.PNGCode.PNG

0 Kudos
3,890 Views
sukruthrameshba
Contributor III

Hello Mr Stancik,

Thank you so much for responding. I am using sample code named "MPC5668x-FlexCAN-Tx2RxFIFO".

As per my knowledge, right baud rate is being used. And i modified the code to use FLEX CAN_F port.

But still i am getting an error. If yolu have any inputs, please let me know.

0 Kudos
3,890 Views
PetrS
NXP TechSupport
NXP TechSupport

Can you share your modification of that sample code?

3,890 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

What sample code do you use? Do you communicate between MCUs FlexCAN modules or with some external device?

It looks either pins are not properly configured or wrong CAN bit timing is used.

A Stuff error must be detected and interpreted as such at the bit time of the sixth consecutive equal bit level (6 consecutive dominant or 6 consecutive recessive levels), in a message field which should be coded by the method of bit stuffing.

Stuff bits produce edges in the bit stream for the purpose of resynchronization.

This all lead for the issue with the bit timing, as I mentioned above.

For the Can bit timing calculation you can refer to a following document;

https://community.nxp.com/docs/DOC-330446

BR, Petr

3,890 Views
sukruthrameshba
Contributor III

Dear Petr,

We are discussing with you in the NXP community discussion.

We have attached the code, where we were trying to use CAN F and standard CAN ID for transmission. We are getting stuff error and stuck in case 1 for CAN F’s Tx flag for successful transmission. we checked for Bit timing also.

Could you please check and provide quick update and it will help to proceed further.

Thanks in advance for your support

0 Kudos