0

I'm trying to set up my mcp2515 with a VP230 Can transceiver for can communication. so far, I am able to connect the mcp to my RPI using SPI bus 0 and to set it up as can0 in RPI. However, when I tried to set the communication up, it seems like it was set up when I run the command "ip -d -s link show can0" However when I run the command "dmesg | fgrep -i can" it showed that the can bit-timing is not yet defined.

I'm pretty new to RPI and Can devices, so any advice would definitely help! Thanks

Able to establish bit timing for MCP2515 spi bus.

image of terminal message

edit! it seems like my spidev is set up for spidev0.1 and spidev6.0 my /boot/config.txt file for spi is as follows dtparam=spi=on dtoverlay=spi6-1cs, cs0_pin=18 dtoverlay=mcp2515-can0, cs0_pin=8, oscillator=8000000, interrupt=25

I'm not sure if is it due to the spidev difference that causes my spi bit-timing to not be set.

spidev img

9
  • 1
    Have you tried: sudo ip link set can0 type can bitrate 500000? Or whatever matches your specific network?
    – Sanders
    Apr 28, 2023 at 2:17
  • hi sanders, thanks for the comment. yes i did tried it out. which is why my "ip -d -s link show can0" has a bitrate of 500000. which i find it surprising why i am able to set the bitrate for the can device.
    – Ber
    Apr 28, 2023 at 2:29
  • 1
    Ok, see if this works: sudo ip link set can0 type can bitrate 500000 dbitrate 2000000 berr-reporting on fd on. If that doesn't work, I know this seems obvious, but restart the raspberry pi and re-do the configuration commands. If that doesn't work - have you checked the wiring & power supply?
    – Sanders
    Apr 28, 2023 at 2:41
  • hmm the terminal returns "RTNETLINK answers: Operation not supported" But surprisingly when i just run "sudo ip link set can0 type can bitrate 500000" it is able to set the can device bitrate. but when i use "dmesg | fgrep -i can" it shows that the can bit-timing is not yet defined.
    – Ber
    Apr 28, 2023 at 3:04
  • Run candump can0 to start listening for CAN messages on the can0 interface, and see if there are any error messages or other issues reported.
    – Sanders
    Apr 28, 2023 at 3:44

2 Answers 2

0

I tried to edit the /boot/config.txt file from

dtoverlay=mcp2515-can0,interrupt=25,oscillator=8000000

to

dtoverlay=mcp2515,spi0-0,interrupt=25,oscillator=8000000

It seems like its due the kernel version change. Source of information is from another forum (https://github.com/linux-can/can-utils/issues/359#issuecomment-1119666048)

0

Per the data sheet https://ww1.microchip.com/downloads/aemDocuments/documents/APID/ProductDocuments/DataSheets/MCP2515-Family-Data-Sheet-DS20001801K.pdf the High-Speed SPI Interface can opperate upto 10 MHz in SPI Modes 0,0 and 1,1. It also has a crystal or oscillator input, you need to program for that.Hopefully this will get you started. I cannot read the fuzzy screen shots you posted so this is a bit of a SWAG.

As you probably know you will need a receiver on the CAN network when trying to transmit a message.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.