All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
To: Tomoya MORINAGA <tomoya-linux-ECg8zkTtlr0C6LszWs/t0g@public.gmane.org>
Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org,
	netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: About bittiming calculation result
Date: Mon, 07 Feb 2011 16:52:53 +0100	[thread overview]
Message-ID: <4D501555.5000905@grandegger.com> (raw)
In-Reply-To: <4D4FDEF9.2030305-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>

On 02/07/2011 01:00 PM, Wolfgang Grandegger wrote:
> Hi Tomoya,
> 
> On 02/07/2011 12:38 PM, Tomoya MORINAGA wrote:
>> Hi,
>>
>> I have a question for bittiming-value calculated by Can-core.
>>
>> In case setting like below,
>>  - ip link set can0 type can bitrate 800000
>>  - clock=50MHz
>>  - Use pch_can
>>
>> Can-core calculates like below
>> brp=21
>> seg1=1
>> seg2=1
>> sjw=1
>> prop_seg=0
>>
>> Is "prop_seg=0" true ?
> 
> Well, only prop_seg+phase_seg=tseg1 is relevant and the pch_can driver
> sets the allowed minimum "tseg1_min1" currently to 1:
> 
> static struct can_bittiming_const pch_can_bittiming_const = {
>         .name = KBUILD_MODNAME,
>         .tseg1_min = 1,
>         .tseg1_max = 16,
>         .tseg2_min = 1,
>         .tseg2_max = 8,
>         .sjw_max = 4,
>         .brp_min = 1,
>         .brp_max = 1024, /* 6bit + extended 4bit */
>         .brp_inc = 1,
> };
> 
>> seg1/seg2/sjw/prop_seg must be more than 1 ?
> 
> Then "tseg1_min" should be set to *2*.
> 
>> Also I can see the following kernel error log.
>> bitrate error 0.7%
> 
> A clock frequency of 50 MHz is sub-optimal for CAN and some
> bit-rates cannot be reproduced properly. Here is the output of
> the can-utils program "can-calc-bit-timing" (with an entry for
> the pch-can added):
> 
> $ ./can-calc-bit-timing pch-can
> Bit timing parameters for pch-can with 50.000000 MHz ref clock
> nominal                                 real Bitrt   nom  real SampP
> Bitrate TQ[ns] PrS PhS1 PhS2 SJW BRP Bitrate Error SampP SampP Error CNF1 CNF2 CNF3
> 1000000    100   3    3    3   1   5 1000000  0.0% 75.0% 70.0%  6.7% 0x05 0x92 0x02
>  800000    420   0    1    1   1  21  793650  0.8% 80.0% 66.6% 16.8% 0x15 0xff 0x00
>  500000    100   8    8    3   1   5  500000  0.0% 87.5% 85.0%  2.9% 0x05 0xbf 0x02
>  250000    500   3    3    1   1  25  250000  0.0% 87.5% 87.5%  0.0% 0x19 0x92 0x00
>  125000    500   6    7    2   1  25  125000  0.0% 87.5% 87.5%  0.0% 0x19 0xb5 0x01
>  100000    500   8    8    3   1  25  100000  0.0% 87.5% 85.0%  2.9% 0x19 0xbf 0x02
>   50000   2500   3    3    1   1 125   50000  0.0% 87.5% 87.5%  0.0% 0x7d 0x92 0x00
>   20000   2500   8    8    3   1 125   20000  0.0% 87.5% 85.0%  2.9% 0x7d 0xbf 0x02
>   10000  12500   3    3    1   1 625   10000  0.0% 87.5% 87.5%  0.0% 0x71 0x92 0x00
> 
> As you can see, especially 800000 gives rather bad results.

BTW, it's always possible to specify optimized bit-timing parameters
directly, e.g. the following seem better:

   800000     60  12    4    4   4   3  793650  0.8% 80.0% 81.0%  1.2%

You could set these with:

  $ ip link set can0 type can \
    tq 60 prop-seg 12 phase-seg1 4 phase-seg2 4 sjw 4

Wolfgang.

WARNING: multiple messages have this Message-ID (diff)
From: Wolfgang Grandegger <wg@grandegger.com>
To: Tomoya MORINAGA <tomoya-linux@dsn.okisemi.com>
Cc: socketcan-core@lists.berlios.de, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: About bittiming calculation result
Date: Mon, 07 Feb 2011 16:52:53 +0100	[thread overview]
Message-ID: <4D501555.5000905@grandegger.com> (raw)
In-Reply-To: <4D4FDEF9.2030305@grandegger.com>

On 02/07/2011 01:00 PM, Wolfgang Grandegger wrote:
> Hi Tomoya,
> 
> On 02/07/2011 12:38 PM, Tomoya MORINAGA wrote:
>> Hi,
>>
>> I have a question for bittiming-value calculated by Can-core.
>>
>> In case setting like below,
>>  - ip link set can0 type can bitrate 800000
>>  - clock=50MHz
>>  - Use pch_can
>>
>> Can-core calculates like below
>> brp=21
>> seg1=1
>> seg2=1
>> sjw=1
>> prop_seg=0
>>
>> Is "prop_seg=0" true ?
> 
> Well, only prop_seg+phase_seg=tseg1 is relevant and the pch_can driver
> sets the allowed minimum "tseg1_min1" currently to 1:
> 
> static struct can_bittiming_const pch_can_bittiming_const = {
>         .name = KBUILD_MODNAME,
>         .tseg1_min = 1,
>         .tseg1_max = 16,
>         .tseg2_min = 1,
>         .tseg2_max = 8,
>         .sjw_max = 4,
>         .brp_min = 1,
>         .brp_max = 1024, /* 6bit + extended 4bit */
>         .brp_inc = 1,
> };
> 
>> seg1/seg2/sjw/prop_seg must be more than 1 ?
> 
> Then "tseg1_min" should be set to *2*.
> 
>> Also I can see the following kernel error log.
>> bitrate error 0.7%
> 
> A clock frequency of 50 MHz is sub-optimal for CAN and some
> bit-rates cannot be reproduced properly. Here is the output of
> the can-utils program "can-calc-bit-timing" (with an entry for
> the pch-can added):
> 
> $ ./can-calc-bit-timing pch-can
> Bit timing parameters for pch-can with 50.000000 MHz ref clock
> nominal                                 real Bitrt   nom  real SampP
> Bitrate TQ[ns] PrS PhS1 PhS2 SJW BRP Bitrate Error SampP SampP Error CNF1 CNF2 CNF3
> 1000000    100   3    3    3   1   5 1000000  0.0% 75.0% 70.0%  6.7% 0x05 0x92 0x02
>  800000    420   0    1    1   1  21  793650  0.8% 80.0% 66.6% 16.8% 0x15 0xff 0x00
>  500000    100   8    8    3   1   5  500000  0.0% 87.5% 85.0%  2.9% 0x05 0xbf 0x02
>  250000    500   3    3    1   1  25  250000  0.0% 87.5% 87.5%  0.0% 0x19 0x92 0x00
>  125000    500   6    7    2   1  25  125000  0.0% 87.5% 87.5%  0.0% 0x19 0xb5 0x01
>  100000    500   8    8    3   1  25  100000  0.0% 87.5% 85.0%  2.9% 0x19 0xbf 0x02
>   50000   2500   3    3    1   1 125   50000  0.0% 87.5% 87.5%  0.0% 0x7d 0x92 0x00
>   20000   2500   8    8    3   1 125   20000  0.0% 87.5% 85.0%  2.9% 0x7d 0xbf 0x02
>   10000  12500   3    3    1   1 625   10000  0.0% 87.5% 87.5%  0.0% 0x71 0x92 0x00
> 
> As you can see, especially 800000 gives rather bad results.

BTW, it's always possible to specify optimized bit-timing parameters
directly, e.g. the following seem better:

   800000     60  12    4    4   4   3  793650  0.8% 80.0% 81.0%  1.2%

You could set these with:

  $ ip link set can0 type can \
    tq 60 prop-seg 12 phase-seg1 4 phase-seg2 4 sjw 4

Wolfgang.

  parent reply	other threads:[~2011-02-07 15:52 UTC|newest]

Thread overview: 101+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-04 12:22 [PATCH 00/20] world-writable files in sysfs and debugfs Vasiliy Kulikov
2011-02-04 12:22 ` Vasiliy Kulikov
2011-02-04 12:22 ` Vasiliy Kulikov
2011-02-04 12:22 ` Vasiliy Kulikov
2011-02-04 12:23 ` [PATCH 01/20] mach-omap2: mux: world-writable debugfs files Vasiliy Kulikov
2011-02-04 12:23   ` Vasiliy Kulikov
2011-02-04 20:09   ` Tony Lindgren
2011-02-04 20:09     ` Tony Lindgren
2011-02-04 12:23 ` [PATCH 02/20] mach-omap2: pm: world-writable debugfs timer files Vasiliy Kulikov
2011-02-04 12:23   ` Vasiliy Kulikov
2011-02-04 20:10   ` Tony Lindgren
2011-02-04 20:10     ` Tony Lindgren
2011-02-04 22:53   ` Kevin Hilman
2011-02-04 22:53     ` Kevin Hilman
2011-02-04 12:23 ` [PATCH 03/20] mach-omap2: smartreflex: world-writable debugfs voltage files Vasiliy Kulikov
2011-02-04 12:23   ` Vasiliy Kulikov
2011-02-04 20:10   ` Tony Lindgren
2011-02-04 20:10     ` Tony Lindgren
2011-02-04 22:54   ` Kevin Hilman
2011-02-04 22:54     ` Kevin Hilman
2011-02-07  5:33     ` Menon, Nishanth
2011-02-07  5:33       ` Menon, Nishanth
2011-02-04 12:23 ` [PATCH 04/20] mach-ux500: mbox-db5500: world-writable sysfs fifo file Vasiliy Kulikov
2011-02-04 12:23   ` Vasiliy Kulikov
2011-02-04 12:23 ` [PATCH 05/20] leds: lp5521: world-writable sysfs engine* files Vasiliy Kulikov
2011-02-04 12:23 ` [PATCH 06/20] leds: lp5523: world-writable engine* sysfs files Vasiliy Kulikov
2011-02-04 12:23 ` [PATCH 07/20] video: sn9c102: world-wirtable " Vasiliy Kulikov
2011-02-04 15:29   ` Mauro Carvalho Chehab
2011-02-04 20:28   ` Luca Risolia
2011-02-04 12:23 ` [PATCH 08/20] mfd: ab3100: world-writable debugfs *_priv files Vasiliy Kulikov
2011-02-04 12:23   ` Vasiliy Kulikov
2011-02-18 17:01   ` Vasiliy Kulikov
2011-02-04 12:23 ` [PATCH 09/20] mfd: ab3500: world-writable debugfs register-* files Vasiliy Kulikov
2011-02-04 12:23   ` Vasiliy Kulikov
2011-02-04 12:23 ` [PATCH 10/20] mfd: ab8500: " Vasiliy Kulikov
2011-02-04 12:23   ` Vasiliy Kulikov
2011-02-04 12:23 ` [PATCH 11/20] misc: ep93xx_pwm: world-writable sysfs files Vasiliy Kulikov
2011-02-04 12:23 ` [PATCH 12/20] net: can: at91_can: " Vasiliy Kulikov
     [not found]   ` <a6800dc8b0daed78256f98f52844cbbb48f4a76d.1296818921.git.segoon-cxoSlKxDwOJWk0Htik3J/w@public.gmane.org>
2011-02-04 12:42     ` Kurt Van Dijck
2011-02-04 12:42       ` Kurt Van Dijck
     [not found]       ` <20110204124233.GB334-MxZ6Iy/zr/UdbCeoMzGj59i2O/JbrIOy@public.gmane.org>
2011-02-04 21:06         ` David Miller
2011-02-04 21:06           ` David Miller
2011-02-07 11:38           ` About bittiming calculation result Tomoya MORINAGA
     [not found]             ` <5009516791F146C49C73FAC57C437313-c0cKtqp5df7I9507bXv2FdBPR1lH4CV8@public.gmane.org>
2011-02-07 12:00               ` Wolfgang Grandegger
2011-02-07 12:00                 ` Wolfgang Grandegger
     [not found]                 ` <4D4FDEF9.2030305-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2011-02-07 15:52                   ` Wolfgang Grandegger [this message]
2011-02-07 15:52                     ` Wolfgang Grandegger
     [not found]                     ` <4D501555.5000905-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2011-02-08  1:27                       ` Tomoya MORINAGA
2011-02-08  1:27                         ` Tomoya MORINAGA
     [not found]                         ` <93C12206407640199DCDD3A89A333F13-c0cKtqp5df7I9507bXv2FdBPR1lH4CV8@public.gmane.org>
2011-02-08  7:57                           ` Wolfgang Grandegger
2011-02-08  7:57                             ` Wolfgang Grandegger
2011-02-08  1:09                   ` Tomoya MORINAGA
2011-02-08  1:09                     ` Tomoya MORINAGA
     [not found]                     ` <E2BAACFF191C4175854E6B2EB9135BE5-c0cKtqp5df7I9507bXv2FdBPR1lH4CV8@public.gmane.org>
2011-02-08  3:29                       ` Bhupesh SHARMA
2011-02-08  3:29                         ` Bhupesh SHARMA
     [not found]                         ` <D5ECB3C7A6F99444980976A8C6D896384DEE2BE1A7-8vAmw3ZAcdzhJTuQ9jeba9BPR1lH4CV8@public.gmane.org>
2011-02-08  4:11                           ` Tomoya MORINAGA
2011-02-08  4:11                             ` Tomoya MORINAGA
2011-02-04 12:23 ` [PATCH 13/20] net: can: janz-ican3: world-writable sysfs termination file Vasiliy Kulikov
     [not found]   ` <6b49b9521416fbd50214485d3e14e5f254ada4f7.1296818921.git.segoon-cxoSlKxDwOJWk0Htik3J/w@public.gmane.org>
2011-02-04 21:06     ` David Miller
2011-02-04 21:06       ` David Miller
2011-02-04 12:23 ` [PATCH 14/20] platform: x86: acer-wmi: world-writable sysfs threeg file Vasiliy Kulikov
2011-02-04 12:23 ` [PATCH 15/20] platform: x86: asus_acpi: world-writable procfs files Vasiliy Kulikov
2011-02-04 12:23   ` Vasiliy Kulikov
2011-02-04 12:53   ` Corentin Chary
2011-02-04 12:24 ` [PATCH 16/20] platform: x86: tc1100-wmi: world-writable sysfs wireless and jogdial files Vasiliy Kulikov
2011-02-04 12:24 ` [PATCH 17/20] rtc: rtc-ds1511: world-writable sysfs nvram file Vasiliy Kulikov
2011-02-04 12:24 ` [PATCH 18/20] scsi: aic94xx: world-writable sysfs update_bios file Vasiliy Kulikov
2011-02-04 12:24 ` [PATCH 19/20] scsi: iscsi: world-writable sysfs priv_sess file Vasiliy Kulikov
     [not found]   ` <1ca8a99eaadde79e662573d89e4f17a20457fba0.1296818921.git.segoon-cxoSlKxDwOJWk0Htik3J/w@public.gmane.org>
2011-03-13  8:28     ` Mike Christie
2011-03-13  8:28       ` Mike Christie
2011-02-04 12:24 ` [PATCH 20/20] fs: ubifs: world-writable debugfs dump_* files Vasiliy Kulikov
2011-02-04 12:24   ` Vasiliy Kulikov
2011-02-06 15:16   ` Artem Bityutskiy
2011-02-06 15:16     ` Artem Bityutskiy
2011-02-04 13:11 ` [rtc-linux] [PATCH 00/20] world-writable files in sysfs and debugfs Linus Walleij
2011-02-04 13:11   ` Linus Walleij
2011-02-04 13:11   ` Linus Walleij
2011-02-04 13:11   ` Linus Walleij
2011-02-21 11:42 ` Samuel Ortiz
2011-03-12 20:23 ` Vasiliy Kulikov
2011-03-12 20:23   ` Vasiliy Kulikov
2011-03-12 20:23   ` Vasiliy Kulikov
2011-03-14 22:18   ` [Security] " Andrew Morton
2011-03-14 22:18     ` Andrew Morton
2011-03-15  2:26   ` James Bottomley
2011-03-15  2:26     ` James Bottomley
2011-03-15  3:09     ` [Security] " Greg KH
2011-03-15  3:09       ` Greg KH
2011-03-15 11:50       ` James Bottomley
2011-03-15 11:50         ` James Bottomley
2011-03-15 14:18         ` Greg KH
2011-03-15 14:18           ` Greg KH
2011-03-15 14:25           ` James Bottomley
2011-03-15 14:25             ` James Bottomley
2011-03-15 16:08         ` Vasiliy Kulikov
2011-03-15 16:08           ` Vasiliy Kulikov
2011-03-15 16:32           ` James Bottomley
2011-03-15 16:32             ` James Bottomley
2011-03-15 16:32             ` James Bottomley
2011-03-12 20:23 ` Vasiliy Kulikov
2011-03-12 20:23 ` Vasiliy Kulikov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4D501555.5000905@grandegger.com \
    --to=wg-5yr1bzd7o62+xt7jha+gda@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org \
    --cc=tomoya-linux-ECg8zkTtlr0C6LszWs/t0g@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.