We are using Cyclone 5 HPS CAN controllers with socketCAN. Everything works fine but the speed of the bus.
We use 100Mhz clock for CAN controller (defined in HPS clocks in Quartus) and when configuring CAN bus for 125.000 bits/s we obtain around 39.000 bits/s.
We have checked that when listing CAN driver settings (ip -d -s link show can0), 40.000.000 clock is shown, while HPS clock manager configuration registers show that 100Mhz clock is configured.
We have forced the driver to take into consideration 100.000.000 clock when loading by modifying the kernel, but in this case we obtain 15.625 bits/s CAN rate, this is, 8 times slower than intended. When listing CAN driver settings we can see 100.000.000 clock as expected.
Finally, we forced the driver with 12.500.000 clock (8 times smaller than real 100Mhz), and we obtain the expected 125.000 bits/s CAN rate. With this configuration CAN communication is correct. Listing CAN driver settings reports 12.500.000 clock as expected.
We can’t undestand why we should “modify” manually CAN controller clock setting in order to get the real value in the system, and also why we have to divide clock rate by 8 in order to get the desired speed.