radman
Posts: 11
Joined: Wed Jan 15, 2014 5:01 pm

Re: CAN controller

Tue Jan 21, 2014 6:06 am

bertr2d2 wrote:Hi radman,
Here is my setup (old Raspbian 2013-09-25 Kernel 3.6.11+):
- USB2CAN interface from 8devices (BTW: my reference, a good catch) on can0
- PiCAN as can1 using async mcp2515 module
running at 1Mbps with this test code http://lnxpps.de/rpie/pican_test.c
Hi Gerd,
I appreciate all the insight regarding getting the CAN to work on raspberry PI. The USB2CAN from 8devices is really an excellent alternative to other commercial devices of that kind.

Following your directions I got the CAN bus working with 1Mbit. I did following: With these 2 changes the stability of CAN bus DRASTICALLY improved. I'm able to run traffic at 1Mbit without any errors which was impossible before. For my application I'm sending a message every 10ms and each message gets response within 1ms. I can run candump in parallel and it does not disturb the other traffic and it does not crash.

What is the chance of getting these patches into main kernel branch for raspberry pi?
Thank you so very much :D

shanlasani
Posts: 12
Joined: Wed Dec 11, 2013 12:46 am

Re: CAN controller

Wed Jan 22, 2014 7:38 pm

Hi,
My Raspberry Pi is receiving and sending CAN messages but when I go to the desktop mode i.e.
"startx" my keyboard and mouse stops working.... i have followed the steps as given on this website http://skpang.co.uk/catalog/pican-canbu ... -1196.html....

Can anybody help me in this problem... Thanks in advance...
Regards,
Shan

jwhitmore
Posts: 40
Joined: Mon Oct 01, 2012 5:32 pm

Re: CAN controller

Thu Jan 23, 2014 7:29 pm

Hello all, great thread but it takes a bit of getting through these days ;-)

I'm running 3.6.11 kernel with the mcp251x driver installed and running with loopback. I've not connected the Physical CAN Driver chip as yet but loopback is working fine, but I have a few questions.

First off the command "ip -s -d link show can0" is telling me the clock is 8,000,000 but the MCP2515 is connected to a 16MHz crystal and is configured in the board file as 16M wondered why the "ip" command is giving me 8?

My other question is more of a concern. Once I set up the MCP2515 using the command:

ip link set can0 type can bitrate 15000 loopback on

I can no longer configure anything. If I want to change the Baud Rate with the command again I get:

RTNETLINK answers: Device or resource busy

Even when I try to do this after ifconfig can0 down it doesn't accept it.
Although I've not connected to the CAN Network as yet I'm hoping to put the device into Listen mode and change the Baud Rate. There are a few other questions like ifconfig can0 up and down don't seem to do anything on the interface.

Thanks for any pointers.

bertr2d2
Posts: 98
Joined: Wed Aug 08, 2012 10:12 pm

Re: CAN controller

Fri Jan 24, 2014 7:56 am

jwhitmore wrote: First off the command "ip -s -d link show can0" is telling me the clock is 8,000,000 but the MCP2515 is connected to a 16MHz crystal and is configured in the board file as 16M wondered why the "ip" command is giving me 8?
8Mhz is correct - Fosc/2 (16MHz/2) is the base for the CAN bit timing calculation of the MCP2515.

Regards

Gerd
Easy to build CAN-Bus interface:
http://lnxpps.de/rpie

cadsenthilkumar
Posts: 29
Joined: Wed Sep 25, 2013 11:09 am

Re: CAN controller

Fri Jan 24, 2014 8:50 am

Hi shan

shanlasani wrote:Hi,
My Raspberry Pi is receiving and sending CAN messages but when I go to the desktop mode i.e.
"startx" my keyboard and mouse stops working.... i have followed the steps as given on this website http://skpang.co.uk/catalog/pican-canbu ... -1196.html....

Can anybody help me in this problem... Thanks in advance...
Regards,
Shan
Just follow the steps given by daniel as mentioned below.. :)


danjperron wrote:I prefer to have it more automatic,

This is the best method I found so far,

P.S. I'm log as root. If you are not , use the sudo command.

1- from a stock raspbian we need to change the kernel

Code: Select all
cd /tmp
wget http://lnxpps.de/rpie/rpi_can_3611_spi_dma.tar.xz
cd /
tar Jxvf /tmp/rpi_can_3611_spi_dma.tar.xz
depmod -a



reboot

2- We need to update the /etc/modprobe.d/raspi-blacklist.conf file
Enable the spi-bcm2708 driver and blacklist the mcp251x driver

Code: Select all
#blacklist spi-bcm2708
blacklist mcp251x



3- Let's add the spi-config and the new mcp2515 modules in file /etc/modules

Code: Select all
# MCP2515 configuration with /INT on GPIO25 and 16MHz clock
spi-config devices=\
bus=0:cs=0:modalias=mcp2515:speed=10000000:gpioirq=25:pd=20:pds32-0=16000000:pdu32-4=0x2002:force_release

#and of course the mcp2515 driver
mcp2515



4- And now the network can0 auto connect. Add these in the /etc/network/interfaces

Code: Select all
auto can0
iface can0 inet manual
pre-up /sbin/ip link set can0 type can bitrate 125000
up /sbin/ifconfig can0 up
down /sbin/ifconfig can0 down



and reboot!

if everything is ok , the command ifconfig should report something like

Code: Select all
root@RpiTest:~# ifconfig
can0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
UP RUNNING NOARP MTU:16 Metric:1
RX packets:6674 errors:0 dropped:0 overruns:0 frame:0
TX packets:58915 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 lg file transmission:10
RX bytes:6695 (6.5 KiB) TX bytes:176745 (172.6 KiB)



I don't know if this is the best method but it is working fine for me.

Daniel

thankq for daniel

Regards
Senthilkumar R

PonomarevP
Posts: 13
Joined: Fri Jan 24, 2014 11:14 am

Re: CAN controller

Fri Jan 24, 2014 11:27 am

Hello
I have RPi with Raspbian 2013-12-20. I did everything cadsenthilkumar wrote in post above(twice), but I still don't have can0 protocol when I type "ifconfig". The only warnings I had were executing command "depmod -a"

Code: Select all

root@raspberrypi:/# depmod -a
WARNING: could not open /lib/modules/3.6.11+/modules.order: No such file or directory
WARNING: could not open /lib/modules/3.6.11+/modules.builtin: No such file or directory
Can anyone help?
Thanks, Paul

PonomarevP
Posts: 13
Joined: Fri Jan 24, 2014 11:14 am

Re: CAN controller

Fri Jan 24, 2014 11:33 am

This post was a copy of previous. Sorry
Last edited by PonomarevP on Mon Jan 27, 2014 7:51 am, edited 1 time in total.

jwhitmore
Posts: 40
Joined: Mon Oct 01, 2012 5:32 pm

Re: CAN controller

Fri Jan 24, 2014 3:17 pm

Thanks Gerd for your answer on the reported Clock speed of the MCP2515.

I'm still struggling with changing the baud rate of the device. (I'm still in loopback) Once I set an initial baud rate the device will not accept any further config settings. I was hoping to do a listening algorithm to be able to connect to a CAN Network of unknown Baudrate. I've added printk calls to the mcp251x module and I'm confused by the fact that when I call "ifconfig can0 down" it pops right back up again. That might be why I can't change the Baudrate, but why would it not stay down? I'm running to standard changes to the board file and the module blacklist but that's all I've changed. Is this normal? And if it is normal is it Correct?

cadsenthilkumar
Posts: 29
Joined: Wed Sep 25, 2013 11:09 am

Re: CAN controller

Mon Jan 27, 2014 9:54 am

PonomarevP wrote:Hello
I have RPi with Raspbian 2013-12-20. I did everything cadsenthilkumar wrote in post above(twice), but I still don't have can0 protocol when I type "ifconfig". The only warnings I had were executing command "depmod -a"

Code: Select all

root@raspberrypi:/# depmod -a
WARNING: could not open /lib/modules/3.6.11+/modules.order: No such file or directory
WARNING: could not open /lib/modules/3.6.11+/modules.builtin: No such file or directory
Can anyone help?
Thanks, Paul
Hi paul,

Try this.

cd /tmp
sudo wget http://lnxpps.de/rpie/rpi_can_3611_spi_dma.tar.xz
cd /
sudo tar Jxvf /tmp/rpi_can_3611_spi_dma.tar.xz
sudo depmod -a

sudo reboot

Regards
Senthilkumar R

PonomarevP
Posts: 13
Joined: Fri Jan 24, 2014 11:14 am

Re: CAN controller

Mon Jan 27, 2014 10:29 am

Thank you for your reply

Tried to install the update you advised, rebooted raspberry and still nothing. Then I reinstalled whole Raspbian 2013-12-20 and repeated all previous procedure and just changed the update version. Rebooted again and still got only eth0 and lo in my network list

Problem was solved by installing modules version 3.10.27+ to /lib/modules/ from https://github.com/raspberrypi/firmware and rebooting. Now I have can0 in my networks list.

Code: Select all

can0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
          UP RUNNING NOARP  MTU:16  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:10 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
Now I have another problem - CAN does nothing. I mean there is no MOSI signal from RPi on "cansend can0 123#R" and no data on "candump can0". Any solutions? Or at least how to check CAN interface

deja11
Posts: 2
Joined: Mon Jan 27, 2014 6:38 pm

Re: CAN controller

Mon Jan 27, 2014 6:48 pm

HI everyone!

I've tried to get my raspberry work with MCP2515 without success.
I am running 3.6.11+ from lnxpps with module package.

I've connected it to my car and cannot get any traffic, and when i try to send i only fill up the buffer.

When i connect my mcp2515 to an oscilloscope(?) and send one package, i get a unstable line, that not ends, like it keeps sending the same package on and on and on.

This is my interrupts after one packaged sended.

Code: Select all

root@raspberrypi:~# cat /proc/interrupts 
           CPU0       
  3:      40847   ARMCTRL  BCM2708 Timer Tick
 16:    1617050   ARMCTRL  bcm2708_spi.0
 32:     650938   ARMCTRL  dwc_otg, dwc_otg_pcd, dwc_otg_hcd:usb1
 52:     646820   ARMCTRL  BCM2708 GPIO catchall handler
 65:       4489   ARMCTRL  ARM Mailbox IRQ
 66:          1   ARMCTRL  VCHIQ doorbell
 75:          1   ARMCTRL
 77:       7037   ARMCTRL  bcm2708_sdhci (dma)
 80:          6   ARMCTRL  bcm2708_spi.0
 83:         19   ARMCTRL  uart-pl011
 84:      12320   ARMCTRL  mmc0
195:     646820      GPIO  can0
FIQ:              usb_fiq
Err:          0
Anyone know whats wrong?

Oh, i've followed the schematics of the mcp2515 card on lnxpps.de

Zeta
Posts: 72
Joined: Wed Dec 12, 2012 9:51 pm

Re: CAN controller

Mon Jan 27, 2014 11:33 pm

deja11 wrote:When i connect my mcp2515 to an oscilloscope(?) and send one package, i get a unstable line, that not ends, like it keeps sending the same package on and on and on.
As you don't have another CAN device to acknoledge this sent message, the driver constantly retries to send it. The behavior is normal, simply add another device on the bus.

cadsenthilkumar
Posts: 29
Joined: Wed Sep 25, 2013 11:09 am

Re: CAN controller

Tue Jan 28, 2014 4:21 am

PonomarevP wrote:Thank you for your reply

Tried to install the update you advised, rebooted raspberry and still nothing. Then I reinstalled whole Raspbian 2013-12-20 and repeated all previous procedure and just changed the update version. Rebooted again and still got only eth0 and lo in my network list

Problem was solved by installing modules version 3.10.27+ to /lib/modules/ from https://github.com/raspberrypi/firmware and rebooting. Now I have can0 in my networks list.

Code: Select all

can0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
          UP RUNNING NOARP  MTU:16  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:10 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
Now I have another problem - CAN does nothing. I mean there is no MOSI signal from RPi on "cansend can0 123#R" and no data on "candump can0". Any solutions? Or at least how to check CAN interface
Hi paul

Its sounds like good try to send what you getting as output from

root@raspberrypi:~# cat /proc/interrupts

if you getting GPIO can0 increase like below . it means your CAN is working the only thing you required another CAN device at your CAN bus (Can-H and Can-L)to loopback your message send through cansend 123#21312342

"CPU0
3: 40847 ARMCTRL BCM2708 Timer Tick
16: 1617050 ARMCTRL bcm2708_spi.0
32: 650938 ARMCTRL dwc_otg, dwc_otg_pcd, dwc_otg_hcd:usb1
52: 646820 ARMCTRL BCM2708 GPIO catchall handler
65: 4489 ARMCTRL ARM Mailbox IRQ
66: 1 ARMCTRL VCHIQ doorbell
75: 1 ARMCTRL
77: 7037 ARMCTRL bcm2708_sdhci (dma)
80: 6 ARMCTRL bcm2708_spi.0
83: 19 ARMCTRL uart-pl011
84: 12320 ARMCTRL mmc0
195: 646820 GPIO can0
FIQ: usb_fiq
Err: 0 "


Regards
Senthilkumar R

PonomarevP
Posts: 13
Joined: Fri Jan 24, 2014 11:14 am

Re: CAN controller

Tue Jan 28, 2014 8:15 am

Hello, Senthilkumar R

I do have second device on the bus(Arduino with SPI to CAN board). And also I have oscilloscope. When I execute command "cansend can0 123#R" I have nothing on the CAN bus and nothing on the Arduino listener program. When I set Arduino to send CAN signal I see it on oscilloscope, but there is still nothing on "candump can0", though I have GPIO can0 increase

cat /proc/interrupts

Code: Select all

           CPU0       
  3:      35799   ARMCTRL  BCM2708 Timer Tick
 16:       6309   ARMCTRL  bcm2708_spi.0
 32:     496426   ARMCTRL  dwc_otg, dwc_otg_pcd, dwc_otg_hcd:usb1
 52:       1654   ARMCTRL  BCM2708 GPIO catchall handler
 65:       3391   ARMCTRL  ARM Mailbox IRQ
 66:          1   ARMCTRL  VCHIQ doorbell
 75:          1   ARMCTRL
 77:      11847   ARMCTRL  bcm2708_sdhci (dma)
 80:         24   ARMCTRL  bcm2708_spi.0
 83:         19   ARMCTRL  uart-pl011
 84:      21710   ARMCTRL  mmc0
195:       1654      GPIO  can0
FIQ:              usb_fiq
Err:          0
Also I noticed, that I don't have spidev in modules list
lsmod

Code: Select all

Module                  Size  Used by
can_raw                 6148  1 
can                    23604  1 can_raw
mcp251x                 9494  0 
mcp2515                 6109  0 
can_dev                 9485  2 mcp2515,mcp251x
spi_config              9384  0 
spi_bcm2708             7453  0 
And I can't make can0 loopback:

Code: Select all

root@raspberrypi:~# ifconfig can0 down
root@raspberrypi:~# ip link set can0 type can bitrate 500000 loopback on
RTNETLINK answers: Device or resource busy
Schematic taken from http://lnxpps.de/rpie/

Best regards,
Paul

cadsenthilkumar
Posts: 29
Joined: Wed Sep 25, 2013 11:09 am

Re: CAN controller

Tue Jan 28, 2014 9:22 am

PonomarevP wrote:Hello, Senthilkumar R

I do have second device on the bus(Arduino with SPI to CAN board). And also I have oscilloscope. When I execute command "cansend can0 123#R" I have nothing on the CAN bus and nothing on the Arduino listener program. When I set Arduino to send CAN signal I see it on oscilloscope, but there is still nothing on "candump can0", though I have GPIO can0 increase

cat /proc/interrupts

Code: Select all

           CPU0       
  3:      35799   ARMCTRL  BCM2708 Timer Tick
 16:       6309   ARMCTRL  bcm2708_spi.0
 32:     496426   ARMCTRL  dwc_otg, dwc_otg_pcd, dwc_otg_hcd:usb1
 52:       1654   ARMCTRL  BCM2708 GPIO catchall handler
 65:       3391   ARMCTRL  ARM Mailbox IRQ
 66:          1   ARMCTRL  VCHIQ doorbell
 75:          1   ARMCTRL
 77:      11847   ARMCTRL  bcm2708_sdhci (dma)
 80:         24   ARMCTRL  bcm2708_spi.0
 83:         19   ARMCTRL  uart-pl011
 84:      21710   ARMCTRL  mmc0
195:       1654      GPIO  can0
FIQ:              usb_fiq
Err:          0
Also I noticed, that I don't have spidev in modules list
lsmod

Code: Select all

Module                  Size  Used by
can_raw                 6148  1 
can                    23604  1 can_raw
mcp251x                 9494  0 
mcp2515                 6109  0 
can_dev                 9485  2 mcp2515,mcp251x
spi_config              9384  0 
spi_bcm2708             7453  0 
And I can't make can0 loopback:

Code: Select all

root@raspberrypi:~# ifconfig can0 down
root@raspberrypi:~# ip link set can0 type can bitrate 500000 loopback on
RTNETLINK answers: Device or resource busy
Schematic taken from http://lnxpps.de/rpie/

Best regards,
Paul
Hi paul

Good , GPIO can0 getting increase . It means your can driver is working and also it sending data.

Are you connecting 120ohm resistor between CAN-H and CAN-L.Else connect 120ohm and see .
If still you not getting any output try this schematic circuit


http://skpang.co.uk/catalog/images/rasp ... _rev_B.pdf

Regards
Senthilkumar R

deja11
Posts: 2
Joined: Mon Jan 27, 2014 6:38 pm

Re: CAN controller

Tue Jan 28, 2014 3:49 pm

Zeta wrote:
deja11 wrote:When i connect my mcp2515 to an oscilloscope(?) and send one package, i get a unstable line, that not ends, like it keeps sending the same package on and on and on.
As you don't have another CAN device to acknoledge this sent message, the driver constantly retries to send it. The behavior is normal, simply add another device on the bus.
Hi again, thanks for your reply Zeta.

Unfortunately, when i connect it to the can bus in my car i still have the same behavior, is there any other way i can test the functionality?

//Dejja1

PonomarevP
Posts: 13
Joined: Fri Jan 24, 2014 11:14 am

Re: CAN controller

Tue Jan 28, 2014 3:54 pm

Thanks for the link, it helped to make a next step to CAN controller :)
I rebuilt schematic as it is on http://skpang.co.uk/catalog/images/rasp ... _rev_B.pdf and finally I have some signal on CAN bus. Unfortunately my receiver and oscilloscope could not recognize it.
The schematic works fine with Arduino, little bit noisy, but my oscilloscope managed to recognize CAN signal. So the problem is somewhere inside the Raspberry Pi

After some dances around RPi I managed to send signal, but my oscilloscope recognizes only first ID and two bytes of data. What can that mean? Attaching latest picture from oscilloscope
http://s29.postimg.org/yv535mbnb/cansignal1.jpg
Last edited by PonomarevP on Tue Feb 04, 2014 8:25 am, edited 1 time in total.

jeremyhahn
Posts: 1
Joined: Sat Feb 01, 2014 8:42 pm

Re: CAN controller

Sat Feb 01, 2014 8:49 pm

Anyone been able to get the MCP251x / SPI working under the latest 3.10.28 RPI kernel? Everything appears to be loading but when I try to bring up the interface I get Cannot find device "can0". Everything works great using prior kernel's.

sjoes
Posts: 3
Joined: Tue Feb 04, 2014 8:38 pm

Re: CAN controller

Tue Feb 04, 2014 9:02 pm

Hi guys,

since three day I try to get a CAN module running on my rpi.
I'm using the schematics from http://lnxpps.de/rpie/ (I like to do the same like Gerd, connecting the rpi with my model train via the Gleisbox).

I think I followed the exactly steps from this forum. But I don't get up the interface.
I'm using 2013-12-20-wheezy-raspbian. The installation is absolutely fresh, even no raspy-config.
I copied the full output of all my steps to pastebin.
Here is my first step, downloading the patch and applying to the linux (depmod was ok).
http://pastebin.com/8dbk2tQf

In the second step I modified the blacklist, modules and interfaces.
http://pastebin.com/0w17Vuhd

After a reboot no can0 interface exists. But my wlan0 is gone. :(

I tried again to download and install the patch.
http://pastebin.com/dRE7z01C
Now I get ugly depmod messages

Code: Select all

root@raspberrypi:/# depmod -a
WARNING: could not open /lib/modules/3.6.11+/modules.order: No such file or directory
WARNING: could not open /lib/modules/3.6.11+/modules.builtin: No such file or directory
But after a reboot I got an can0 interface. :-)
http://pastebin.com/9ZuKJBew
But I can't set the loop back mode or any thing else.

Code: Select all

root@raspberrypi:/home/pi# ip link set can0 type can bitrate 125000 loopback on
RTNETLINK answers: Device or resource busy
So now I'm really frustrated about this. But I hope that someone from this board can give my a hint.

Best, sjoes.

Ps. Can I use the loopback mode without a connected mcp251x?

Zeta
Posts: 72
Joined: Wed Dec 12, 2012 9:51 pm

Re: CAN controller

Tue Feb 04, 2014 9:44 pm

sjoes wrote:Ps. Can I use the loopback mode without a connected mcp251x?
No : the loopback mode is running inside the MCP2515 and allows to check the communication with it.

Also take care that the mcp2515 optimised driver doesn't support loopback mode. Only the old mcp251x driver supports it, but has troubles sustaining fast messages on 3.6 and higher kernels.
It seems you are using the optimised one if I read your log well. So you have to use it in normal mode (no loopback) and plug another device on the bus to start playing with it.


By the way, it exists what is called a "vcan" (aka virtual can) interface. This runs only on software, and allows to check can is working on the kernel side, and also for some tests to fake a can bus to an app and send it manual messages. Probably not what you need here, but this can be interesting to know.

Zeta

sjoes
Posts: 3
Joined: Tue Feb 04, 2014 8:38 pm

Re: CAN controller

Tue Feb 04, 2014 9:58 pm

Hi Zeta,

my driver doesn't support the loopback. Ok, thats a good to know.
Do I need a really CAN device at the end of my bus?
Or does the MCP receives his own messages when I just terminate the bus with a 120 Ohm resistor?

Zeta
Posts: 72
Joined: Wed Dec 12, 2012 9:51 pm

Re: CAN controller

Tue Feb 04, 2014 10:28 pm

sjoes wrote:my driver doesn't support the loopback. Ok, thats a good to know.
To be clear (words are tricky there), the hardware driver (the MCP2515 chip) supports it, but it is the "optimized" software driver that doesn't support it (the older one supports it but is a bit broken on new hardware).
sjoes wrote:Do I need a really CAN device at the end of my bus?
Yes and no. without another device you will be able to check that it works (interrupts counting and no error on sending the first packet), but shortly after you will begin to have errors about buffer full.
The reason is that one good thing on CAN bus is that every sent message have to be acknoledged by at least one other device. This ensure the message was correctly received at the other end of the line.
You can see this in the picture depicting a frame here : https://en.wikipedia.org/wiki/CAN_bus#Base_frame_format (check the "ACK slot").
So if your device is alone on the bus, you will be able to fill the buffer, but the first frame will be sent forever until one device acknoledges it, and so the buffer will stay full.
sjoes wrote:Or does the MCP receives his own messages when I just terminate the bus with a 120 Ohm resistor?
See above.

PonomarevP
Posts: 13
Joined: Fri Jan 24, 2014 11:14 am

Re: CAN controller

Wed Feb 05, 2014 7:32 am

Hello, sjoes
I tried again to download and install the patch.
http://pastebin.com/dRE7z01C
Now I get ugly depmod messages
This problem can be solved by installing update to fresh Raspbian, but if you have CAN interface in your network list it is not necessary
But after a reboot I got an can0 interface. :-)
http://pastebin.com/9ZuKJBew
But I can't set the loop back mode or any thing else.

First you should turn off your can0 interface by

Code: Select all

ifconfig can0 down
But it won't work, because "ifplugd" process will bring it back to life again, so you should kill this process, then down the interface, set loopback and

Code: Select all

ifconfig can0 up
again

Probably you can't use loopback without mcp2515, because raspberry only sends SPI signal, to get loopback you need to convert it to CAN signal and read it back

Regards, Paul

PonomarevP
Posts: 13
Joined: Fri Jan 24, 2014 11:14 am

Re: CAN controller

Wed Feb 05, 2014 8:21 am

Returning to my problem. I have compared SPI signal from RPi and from Arduino(both with CAN-shields). It appears so, that raspberry SPI signal runs 10 times faster than arduino spi signal on same CAN bitrate. Probably mcp2515 with its 10 MHz SPI just can't catch the signal
Is there possibility to make raspberry SPI slower?

Zeta
Posts: 72
Joined: Wed Dec 12, 2012 9:51 pm

Re: CAN controller

Wed Feb 05, 2014 6:46 pm

PonomarevP wrote:It appears so, that raspberry SPI signal runs 10 times faster than arduino spi signal on same CAN bitrate.
Comparing is good, but measuring would have been better... Which frequency was the SPI signal on the raspi ?
PonomarevP wrote:Probably mcp2515 with its 10 MHz SPI just can't catch the signal
The MCP2515 datasheet will tell you which frequency is possible with a given crystal. As a reference, my own setup is a 10MHz SPI running perfectly using a 20MHz crystal.
PonomarevP wrote:Is there possibility to make raspberry SPI slower?
This is one of the parameters you give when loading the module. There are two parameters about frequency : SPI frequency and MCP2515's crystal frequency (to have the correct CAN baudrate).

Return to “Interfacing (DSI, CSI, I2C, etc.)”