1
\$\begingroup\$

I have one CAN bus interface that's using a 16 MHz crystal, and I want to set up my own interface to talk / simulate CAN packets with first one. I do have 20 MHz crystals for my own interface, but whenever I connect those two together, setup my own to 500 kbaud, the other one discovers only 50 kbaud... therefore this question.

It is worth to mention that the already-setup interface does work flawlessly with vehicle CAN and is verified to work as expected.

Does it matter (in CAN) if the other device uses different crystal?

For those who wonder, this is an Arduino setup though I'm generally curious about this in an electronics setup.

\$\endgroup\$
2
  • \$\begingroup\$ Every device on the bus can be running at a different speed (clocked by any means, including a crystal); however, they all need to be set up to operate at the same baud rate. This is how all shared data buses work. From your post, it sounds like your baud rate is off by a factor of 10, which is likely just an error in the setup of the bus - a single bit in a control register, for example. \$\endgroup\$ – Kurt E. Clothier Oct 29 '15 at 6:28
  • \$\begingroup\$ Ahh i kind of thought it would still work, cause vehicles probably use different setups. Yah, am always getting 50kbaud from working device no matter what, allmost kind of suspect my capacitors (2x 15pF) but im too unfamiliar with those to actually nail it to that specifically. Thanks for quick answer, ill try to debug and see where it fails. I got a suspicion on arduino lib where most libs use baud setup for 16mhz crystals... \$\endgroup\$ – Deko Oct 29 '15 at 6:33
1
\$\begingroup\$

Does it matter (in CAN) if other device uses different crystal ?

No, of course not. Simply set the baudrate correctly for each node. Verify with an oscilloscope.

The CAN spec recommends using quartz oscillators for baudrates above 125kHz. As a rule of thumb, you should pick a crystal value that gives you a maximum deviation of 1% from the optimal baudrate.

You will have to determine which crystal values that are suitable by reading how the clock pre-scaler works for the specific CAN controller. This should be much easier when you have an external controller as in your case, rather than have a built-in one (which is far more common). Just provide a dedicated clock to it.

Also note that clock pre-scalers for CAN might be rather intricate, as you'll have to consider how many time quanta to use per bit and where the sync point ends up. This is usually the hardest part to get right when writing a CAN driver.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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