i.MX6 flexcan does not produce accurate bitrate

cancel
Showing results for 
Search instead for 
Did you mean: 

i.MX6 flexcan does not produce accurate bitrate

1,126 Views
hamid166262
Contributor I

Hi everybody;

I am using i.MX6D, and linux kernel 3.0.35.

I want to utilize flexcan.1, In transmit, it is OK, but in receive, it drops packets occasionally.

I checked it with a counter and noticed that although short packets have been dropped, but packets with 7  or 8 bytes long are dropped frequently.

when I set bitrate to 800K with canconfig (also ip tool), it says:

flexcan imx6q-flexcan.1: bitrate error 1.3%

can1 bitrate: 789473, sample-point: 0.789

flexcan imx6q-flexcan.1: writing ctrl=0x01332006

i checked flexcan driver and in probe clock set as follows:

clk = clk_get(&pdev->dev, NULL);

and in clock.c from arch/arm/mach-mx6, can root clock defined as below:

static struct clk can_clk_root = {

         __INIT_CLK_DEBUG(can_clk_root)

        .parent = &pll3_60M,

        .set_rate = _clk_can_root_set_rate,

        .get_rate = _clk_can_root_get_rate,

        .round_rate = _clk_can_root_round_rate,

};

so it sholud use 24MHz for generating bitrate which must be accurate for 800K. wright?

why it is happening?

thanks in advance

Labels (3)
0 Kudos
2 Replies

250 Views
adamhuang
Contributor III

concerned

0 Kudos

333 Views
igorpadykov
NXP TechSupport
NXP TechSupport

Hi Hamidreza

to be sure (because any software frequency measurements may be inaccurate)

one can measure clock with oscilloscope -

can_clk_root on CLKO pad using CCM_CCOSR register.

In general on custom board there may be unstable 24MHz clock,

one can also check that with oscilloscope.

Alternatively one can run i.mx-test package (selected in ltib) with command

ip link set can0 up type can bitrate 125000

Best regards

chip

-----------------------------------------------------------------------------------------------------------------------

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

-----------------------------------------------------------------------------------------------------------------------

0 Kudos