The nano can use interrupt, you can see the file /opt/nvidia/jetson-gpio/README.txt. in your nano
And this module can support 5, 10, 20, 31.25, 33.33, 40, 50, 80, 100, 125, 200, 250, 500Kbps and 1Mbps CAN speed if it uses a 8MHz Crystal, you can refer to https://github.com/coryjfowler/MCP_CAN_lib/blob/master/mcp_can.cpp
This module can hardly achieve a 90% load if you use a higt CAN speed, because it takes about 4ms ( not sure) to send a frame to the CAN line when you call the sending funcation. You can choose a best CAN speed acroding to you CAN frame length, CAN line lenth and this moudle speed.
The interrupt pin of MCP2515 that you mentioned is NT, CS is the chip select pin which used to enable the moudle to receive data from spi bus, and there are 7 pins, each pin should be connected to nano accrodingly.
I have not tried the setup of CAN communication on NANO. Will try and provide steps needed.
Is there meanwhile someone who has established a CAN communication with the MCP 2515 CAN interface and the MCP 2562 transceiver?
Does anyone have a solution and can provide the steps?
The easiest way to do this if you’re not comfortable programming SPI devices in C in kernel mode is to use a USB CAN interface.
Currently I can not program any SPI devices in kernel mode, but I would like to learn it. So I asked for an example with SPI. CAN to USB is already running.
USB CAN or STM32 board with a CAN transceiver. Forget about SPI and MCP 2515…
-albertr
CAN requires a controller IC and a transciever IC at the hardware level.
Luckily you can buy CAN controller ICs which bridge SPI to CAN.
Therefore it is possible to add a CAN interface to any microntroller or computer with an SPI interface.
You may need to write a driver for it, but if this doesn’t put you off, you’re in business.
Take a look at the newer CAN-FD chipsets. Supports normal CAN 2.0 plus the newer FD standard which can run much faster.
I expect something like this would work:
hello i have some quesstion …
i’m trying to setting a can interface using a USB to CAN.
but it is not working. ToT…
please recommend to any WebSite that i can refer to…
thank you!!!
Hi,
Can you provide exact steps you have followed? and on which board you are trying ?
Thanks,
Shubhi
okay !! Thank you very much~!~!~!
I using a Jetson Nano board!!
- using a PeakSystem USB to CAN converter
- Jetson nano’s USB port are connected with Pcan2 Module’s dSub port on raspberryPi.
*** PCan2 board are connected with Rapsberrypi. (plead see here 태승포장산업사 : 네이버 블로그 )
Can i setting a Something???
i don’t know this board ToT…
Hi,
I have not tried this setup. But you have to add CAN device with some more information under USB clients to make it work.
uhm… how can i add CAN device??
i just set this
→ sudo ip link set can0 up type can bitrate 500000
i really thanks to you
Hi,
I tried MCP2515 SPI-CAN communication on Jetson-Nano recently:
Here are the steps you can follow:
-
Choose a GPIO pin on J41 (40 pin header) and enable interrupts on that pin.
-
Make proper connections from MCP2515 to SPI controller on J41. There are 2 SPI controller present on J41. I have connected two MCP chips on respective SPI controller with INT pin connected to chosen GPIO.
-
Make changes in Nano DTB:
can_clock: can_clock {
compatible = “fixed-clock”;
#clock-cells = <0>;
clock-frequency = <20000000>;
clock-accuracy = <100>;
};
spi@7000d400 { /* SPI 1 to 40 pin header */
status = “okay”;
spi@0 {
compatible = “microchip,mcp2515”;
reg = <0x0>;
spi-max-frequency = <10000000>;
nvidia,enable-hw-based-cs;
nvidia,rx-clk-tap-delay = <0x7>;
clocks = <&can_clock>;
interrupts = <&gpio TEGRA_GPIO(Z, 0) 0x1>; // GPIO pin chosen from 40 pin header
controller-data {
nvidia,cs-setup-clk-count = <0x1e>;
nvidia,cs-hold-clk-count = <0x1e>;
nvidia,rx-clk-tap-delay = <0x1f>;
nvidia,tx-clk-tap-delay = <0x0>;
};}; }; spi@7000d600 { /* SPI 2 to 40 pin header */ status = "okay"; spi@0 { compatible = "microchip,mcp2515"; reg = <0x0>; spi-max-frequency = <10000000>; nvidia,enable-hw-based-cs; nvidia,rx-clk-tap-delay = <0x6>; clocks = <&can_clock>; interrupts = <&gpio TEGRA_GPIO(V, 0) 0x1>; controller-data { nvidia,cs-setup-clk-count = <0x1e>; nvidia,cs-hold-clk-count = <0x1e>; nvidia,rx-clk-tap-delay = <0x1f>; nvidia,tx-clk-tap-delay = <0x0>; }; };
-
Make changes in Nano pinmux and GPIO dtb:
Enable SPI0 and SPI1 with SPI functionality by configuring pins(tristate disable, input enable, change function property…)
Add GPIO entry in gpio-input section.
Flash with the change in DTB.
Now on device after boot, run following commands:
ip link set can0 type can bitrate 500000
ip link set can0 up
ip link set can1 type can bitrate 500000
ip link set can1 up
candump -x any
cansend can0 123#abcdabcd
Thanks,
Shubhi Garg
I just came across this when Googling for documentation on the Nano’s CAN capabilities (apparently none - minor disappointment but no big deal).
As an FYI, the Canable USB to CAN adapter is $30 USD ($60 for the galvanically isolated version) and when flashed with the candlelight firmware appears to be plug-and-play with the Jetson - no need to mess with dtb’s or wiring to the GPIO pins.
(I’m running custom firmware on my canable that fixes endian cleanliness issues, but the Jetson is little endian just like x86 so should work fine with stock firmware.)
Is there any danger to the NANO module in connecting a CAN PHY to nano reserved pins 143 and 145? Reason is we are designing a carrier board that we want to handle both the NANO and NX (and we are exposing this for when an NX is attached obviously) .
Hi william.thompson,
Please help to open a new topic if it’s still an issue. Thanks
Hi, I am new in delevoping with Nvidia devices.
I am trying to use a PiCAN 2 (PiCAN2 - Controller Area Network (CAN) Bus Interface for Raspberry Pi 2) with the jetson nano. When I used it with the Raspberry PI 4, it was just requiered the following configurations into the configuration file (/boot/config.txt):
dtparam=spi=on
dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25
dtoverlay=spi-bcm2835-overlay
I have converted de dtb file into a dts file in order to follow this solution. In the step 3, I decided to use the spi1 with this configuration:
can_clock: can_clock {
compatible = “fixed-clock”;
#clock-cells = <0>;
clock-frequency = <16000000>;
clock-accuracy = <100>;
};
spi@7000d600 { /* SPI 1 to 40 pin header */
status = “okay”;
spi@0 {
compatible = “microchip,mcp2515”;
reg = <0x0>;
spi-max-frequency = <16000000>;
nvidia,enable-hw-based-cs;
nvidia,rx-clk-tap-delay = <0x7>;
clocks = <&can_clock>;
interrupts = <&gpio TEGRA_GPIO(Z, 0) 0x19>; // GPIO pin chosen from 40 pin header, pin 25 like RB Pi 4
controller-data {
nvidia,cs-setup-clk-count = <0x1e>;
nvidia,cs-hold-clk-count = <0x1e>;
nvidia,rx-clk-tap-delay = <0x1f>;
nvidia,tx-clk-tap-delay = <0x0>;
};
};
};
I understand that the pin 25 is chosen for the interrup in the case of the Raspberry Pi, and I decided to select the same pin on the jetson since both are compatible
Then, in the step 4 I did some changes in the input and tristate from 0x1 to 0x0 like in the example below. But, I don’t know how to change the function property, and how to add the GPIO entry.
spi1_mosi_pc0 {
nvidia,pins = "spi1_mosi_pc0";
nvidia,function = "rsvd1";
nvidia,pull = <0x1>;
nvidia,tristate = <0x0>;
nvidia,enable-input = <0x1>;
};
I would appreciate any help with my doubts.
Please help to open a new topic if it’s still an issue. Thanks