首页 > 其他分享 >瑞芯微CAN收发数据错误

瑞芯微CAN收发数据错误

时间:2023-02-09 09:45:30浏览次数:45  
标签:错误 .. state sjw brp 收发 瑞芯微 link phase

------------------------------------结论-------------------------------
CAN0无法收到数据,RX发现很多错误针,都是时钟调整不合适,正确修改如下:
assigned-clock-rates = <200000000>;

--------------------------以下是分析过程--------------------------
------------------------1.公式----------------
amplePoint=
(1+PROP_SEG+PHASE_SEG1+PHASE_SEG2)
(1+PROP_SEG+PHASE_SEG1)

波特率 = CAN总线时钟频率 / (1 + Time Segment1 + Time Segment2)
采样点 =( 1 + Time Segment1)/ (1 + Time Segment1 + Time Segment2)

-------------------------2.ROCKCHP报文------------------------
5] root@localhost:~# ip -details link show can0
[10:56:25.324] 3: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UP mode DEFAULT group default qlen 4096
[10:56:25.335] link/can promiscuity 0 minmtu 0 maxmtu 0
[10:56:25.335] can state ERROR-PASSIVE (berr-counter tx 0 rx 129) restart-ms 0
[10:56:25.335] bitrate 250000 sample-point 0.875
[10:56:25.343] tq 250 prop-seg 6 phase-seg1 7 phase-seg2 2 sjw 1
[10:56:25.343] rockchip_can: tseg1 1..16 tseg2 1..8 sjw 1..4 brp 1..128 brp-inc 2
[10:56:25.354] clock 200000000 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535

(1+6+7)/(1+6+7+2)=0.875


root@localhost:/home/artc# ip -details link show dev can0
3: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UP mode DEFAULT group default qlen 10
link/can promiscuity 0 minmtu 0 maxmtu 0
can state ERROR-WARNING (berr-counter tx 0 rx 129) restart-ms 0
bitrate 500000 sample-point 0.875
tq 250 prop-seg 3 phase-seg1 3 phase-seg2 1 sjw 1
rockchip_can: tseg1 1..16 tseg2 1..8 sjw 1..4 brp 1..128 brp-inc 2
clock 200000000 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
root@localhost:/home/artc#

 

root@localhost:/home/artc# ip -d -s -h link show dev can0
3: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UP mode DEFAULT group default qlen 10
link/can promiscuity 0 minmtu 0 maxmtu 0
can state ERROR-WARNING (berr-counter tx 0 rx 130) restart-ms 0
bitrate 500000 sample-point 0.850
tq 100 prop-seg 8 phase-seg1 8 phase-seg2 3 sjw 1
rockchip_can: tseg1 1..16 tseg2 1..8 sjw 1..4 brp 1..128 brp-inc 2
clock 100000000
re-started bus-errors arbit-lost error-warn error-pass bus-off
0 863730 0 0 1 0 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
RX: bytes packets errors dropped overrun mcast
6.91M 864k 864k 0 1 0
TX: bytes packets errors dropped carrier collsns
0 0 0 0 0 0
root@localhost:/home/artc#

 

0 0 0 0 0 0
root@localhost:/home/artc# ip -d -s -h link show dev can0
3: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UP mode DEFAULT group default qlen 10
link/can promiscuity 0 minmtu 0 maxmtu 0
can state ERROR-PASSIVE (berr-counter tx 0 rx 130) restart-ms 0
bitrate 501689 sample-point 0.750
tq 498 prop-seg 1 phase-seg1 1 phase-seg2 1 sjw 1
rockchip_can: tseg1 1..16 tseg2 1..8 sjw 1..4 brp 1..128 brp-inc 2
clock 148500000
re-started bus-errors arbit-lost error-warn error-pass bus-off
0 1748265 0 0 1 0 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
RX: bytes packets errors dropped overrun mcast
14.0M 1.75M 1.75M 0 1 0
TX: bytes packets errors dropped carrier collsns
0 0 0 0 0 0

 

----------------------------3.ZLG的报文--------------------

root@M6708-T:~/radar/ArtcBin# ip -details link show can0s
2: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN mode DEFAULT group default qlen 4096
link/can promiscuity 0
can state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0
bitrate 500000 sample-point 0.866
tq 133 prop-seg 6 phase-seg1 6 phase-seg2 2 sjw 1
flexcan: tseg1 4..16 tseg2 2..8 sjw 1..4 brp 1..256 brp-inc 1
clock 30000000

(1+6+6)/(1+6+6+2)=13/15=0.866



//设置波特率
ip link set can0 type can bitrate 500000
//设置采样点--
ip link set can0 type can tq 133 prop-seg 6 phase-seg1 6 phase-seg2 2 sjw 1
ip link set can0 type can tq 250 prop-seg 3 phase-seg1 3 phase-seg2 1 sjw 1

标签:错误,..,state,sjw,brp,收发,瑞芯微,link,phase
From: https://www.cnblogs.com/loongson-artc-lyc/p/17104142.html

相关文章