Flexcan configuration in linux

cancel
Showing results for 
Search instead for 
Did you mean: 

Flexcan configuration in linux

447 Views
slopez
Contributor II

Hi, all!

I have an STKa6Ulx development board with a TQMa6ulx embedded system. I'm trying to start the CAN bus. The board, has two CAN interfaces. I've developed two applications to send and receive data over the CAN. If I connect CAN0 to CAN1 the data is sent and received correctly.

However, I want to communicate the embedded system with a  HC12 micro controller system over the CAN. The HC12 has the follow configuration in the busCAN:

BAUDRATE CAN: 250000

Sinc Jum: 2

T. Seg 1: 11

T. Seg 2: 4

I don't know how to establish this configuration via linux terminal. If I show the can0 configuration in terminal I get the follow data:

pastedImage_2.png

In the image, I see the data 'flexcan' but I don't know how to acces to that configuration.

I've connected both system, but I can't communicate each other.

Please, Could someone helps me?


Thanks, Santi.

Labels (3)
0 Kudos
5 Replies

254 Views
igorpadykov
NXP TechSupport
NXP TechSupport

Hi Santiago

basic flexcan tests are described on

doc\can\test - imx-test - i.MX Driver Test Application Software 

Controller Area Network (CAN) 

Since this board is third party board, issue may be posted on vendor support portal

TQ | Support 

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

254 Views
slopez
Contributor II

Hi, Igor.

Now I know how to configure the values of the buscan. My problem is, the values of the configuration doesn't match between two system.

If I use can-calc-bit-timming I get the follow information

path879-3.png

It's possible to change the ref clock in buscan in linux?

I check /sys/kernel/debug/clk/clk_summary and I see the bus can is using PLL3, Can I configure other bus clock for the buscan?

pastedImage_2.png

Regards, Santi.

0 Kudos

254 Views
TomE
Specialist I

That's close enough.

For a simple CAN bus there's only one parameter that matters. That's the resulting BIT rate, in your case 250,000. The input clock divided by the prescaler gets you the "Time Quanta". The sum of the two Phase Segments, the Prop Segment plus one divide that down to get the bit rate. In your two examples they're 250ns by 16 and 266ns by 15. They add up to the same thing.

If (and only if) you're pushing the CAN bus to either its maximum possible physical length, or the maximum ability to handle inaccurate oscillators, then there are ways to "tune" those parameters to optimise for distance (with a large propagation segment to handle the delays), or large PS1 and PS2 (so you can get a large SJW) so it can lock onto clocks up to 1% away from what it is meant to be.

Some manufacturers (GM) specify a recommended "Sample Point", which is where the point between the two phase segments should appear as a percentage of the bit width. That's the "sweet spot" that they know gives the best result for them.

Nobody I know of uses the "triple sampling" feature.

Tom

0 Kudos

254 Views
igorpadykov
NXP TechSupport
NXP TechSupport

Hi Santi

one can look at basic can tests description on

CAN (Linux) 

Controller Area Network (CAN) 

Best regards
igor

0 Kudos

254 Views
slopez
Contributor II

Hi, Igor!

Thanks a lot for your response, I found those links before make the post in the forum, but doesn't helped me.

I've asked on vendor support portal.

Thanks,

Santi.

0 Kudos