How to change frequency of CAN interface

Hi
I faced an issue while testing the CAN interface on Jetson Xavier nx,
CAN interface on my board has a frequency of 34MHz and the slave device that I am using has a frequency of 40MHz. Hence the data exchange was not taking place.
Is there a way to change this frequency of CAN on board??
Thanks
Ashik P.

Hi ashik.p,

To achieve 40MHz, first you need to set CAN parent clock as pllaon.
Please follow below doc to do so:
https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%2520Linux%2520Driver%2520Package%2520Development%2520Guide%2Fclocks.html%23wwpID0E06B0HA

Check “ To use PLLAON as clock source” section

Also, by default, CAN clock rate requested is 50MHz from MTTCAN kernel driver. So to use 40MHz, make below change in driver:
The mttcan kernel driver sets the CAN clock rate. Follow the instructions in the Kernel Customization topic’s section Obtaining the Kernel Sources with Git to obtain kernel source code, then update the clock rate in the mttcan driver as in this code snippet:

.set_can_core_clk = true,

.can_core_clk_rate = 50000000, //// modify here (in Hz)

.can_clk_rate = 200000000, //// four times of core clk rate

Build the kernel and flash with the new kernel Image.
You can also directly copy mttcan.ko in the target under /lib/…

Let me know if you face any issues.

Thanks,
Shubhi

Thanks for the instructions, i will try that out
Ashik P.