How to using CAN In nx devkit

Hi everyone:
I want to test CAN in NX devkit.could you give some tip to using CAN.

Hi leetop,
Below the board, you will find J17 where 4 pins are available (CAN RX, TX, VCC, GND), you may need to rework the board to use these pins.
Only one CAN controller is available to use in NX.
Update CAN pinmux registers :
0x0c303000 = 0x0000c400;
0x0c303008 = 0x0000c458;
and you are good to go.

Thanks,
Shubhi

Hi shgarg:
ls there any device I need to test CAN? And could you give a example about test CAN step by step?
Thanks a lot .

Hi leetop,
Connect a transceiver something like this: https://www.amazon.in/xcluma-Sn65Hvd230-Transceiver-Communication-Module/dp/B072TCPSB1/ref=sr_1_1?crid=1UF4TU4O2J0M1&dchild=1&keywords=can+transceiver&qid=1590119310&sprefix=CAN+tra%2Caps%2C379&sr=8-1

  1. Connect RX of transceiver to CAN_RX of J17
  2. Same with other 3 pins
  3. Update pinmux registers mentioned above
  4. load kernel modules:
    modprobe can
    modprobe can-raw
    modprobe mttcan
  5. Make can interface up on network with bitrate 500kbps:
    ip link set can0 up type can bitrate 500000
    Your can0 node is ready to transfer packets, you can connect other CAN nodes on bus via CANH and CANL pins of transceiver.
  6. send message from can0
    cansend can0 123#abcdabcd
  7. receive message in can0
    candump can0
    For all these steps, you will need to connect one more CAN node on bus.

If you do not have other CAN device or transceiver:
you can do loopback test:

  1. Connect CAN_RX of J17 to CAN_TX of J17
  2. Update pinmux registers mentioned above
  3. load kernel modules:
    modprobe can
    modprobe can-raw
    modprobe mttcan
  4. Make can interface up on network with bitrate 500kbps:
    ip link set can0 up type can bitrate 500000 loopback on
  5. candump can0 &
  6. cansend can0 123#abcdabcd

Thanks,
Shubhi

Can someone from Nvidia briefly describe the capabilities of the can controller inside NX module? I assume it can do 29-bit id’s (can 2.0b format), but can it go can FD? What max data rate it can support?

-albertr

Hi albertr,
Yes it can go can FD with max data bitrate of 5Mbps currently. You can increase data bitrate further by configuring tdcr register with value depends on transceiver used.
Ex.
echo 0x600 > /sys/devices/c320000.mttcan/net/can0/tdcr

Thanks,
Shubhi

Hi shgarg,
I am now looking at the J17 CAN on the NX devkit.

My question:
Is the setting of 0x0c303000 and 0x0c303008 necessary for J17?

Linux_for_Tegra/bootloader/t186ref/BCT/tegra19x-mb1-pinmux-p3668-a01.cfg in the Jetson_Linux_R32.4.2_aarch64.tbz2, it shows can0 pinmux addresses 0x0c303010 and 0x0c303018, which are already enabled.

#### Pinmux for used pins ####
pinmux.0x0c303010 = 0x0000c400; # can0_dout_paa2: can0, tristate-disable, input-disable
pinmux.0x0c303018 = 0x0000c450; # can0_din_paa3: can0, tristate-enable, input-enable
#### Pinmux for unused pins for low-power configuration ####
pinmux.0x0c303000 = 0x0000c415; # can1_dout_paa0: rsvd1, pull-down, tristate-enable, input-disable
pinmux.0x0c303008 = 0x0000c415; # can1_din_paa1: rsvd1, pull-down, tristate-enable, input-disable

J17 CAN can communicate even if the memory address is rewritten to the default value.

sudo busybox devmem 0x0c303000 32 0x0000c415
sudo busybox devmem 0x0c303008 32 0x0000c415

Hi naisy,
No, it is not required if already enabled.

Hi shgarg,
It’s clear. Thank you very much.