7
\$\begingroup\$

I am trying to get the ECAN functionality working on a dsPIC33. I have two identical dsPIC33s, each with identical CAN transceivers connected by a short (3 inch) bus. One is transmitting, one is receiving. However, I see no messages, I just see a repeating waveform with a period of 34.5us. Does this suggest a particular error condition on a CAN bus?

Logic analyser on TX & RX

\$\endgroup\$
2
  • \$\begingroup\$ Could you add the bit timing parameters to your question, especially the intended baudrate? You should also note, that there is no line called "CAN RX" or "CAN TX", this is not how CAN works: CAN has a pair of lines, which are shared by all nodes on the bus, the access to the medium is negotiated by the arbitration process. \$\endgroup\$
    – 0x6d64
    Sep 12 '11 at 6:48
  • 1
    \$\begingroup\$ There are lines called CAN TX and CAN RX on the transceiver. Sorry, I should have mentioned that, but I assumed it would be obvious. \$\endgroup\$ Sep 12 '11 at 13:13
10
\$\begingroup\$

Turns out the answer should have been obvious from the waveforms above.

When TX goes low, so does RX. But when TX goes high, RX takes more than 1us to rise again. That's more than a whole bit time! CAN cannot work under these conditions.

The reason RX lags behind TX would have been obvious with a proper oscilloscope, rather than a simple logic analyser. Since the bus was so short, I didn't bother to add the termination resistors, because I didn't think reflections would be a problem. But the resistors are also important for discharging the slight capacitance of the bus, allowing it to transition from dominant back to recessive fast enough.

Soldering on the resistors magically made whole CAN messages appear.

\$\endgroup\$
2
  • \$\begingroup\$ That was what my suggestion was going to be :) \$\endgroup\$ Sep 12 '11 at 13:21
  • \$\begingroup\$ I really should have known better. I've only been using CAN buses for 10 years now. \$\endgroup\$ Sep 12 '11 at 18:12
4
\$\begingroup\$

There is nothing magic about the terminating resistors. They are absolutely required for a CAN bus. They may be called "terminating" resistors, and this is indeed part of their function when the bus is long enough to be a transmission line. However, they also cause a unloaded bus to go to the recessive state, which is a fundamentail assumption the CAN protocol is based on.

Think of CAN as a passively pulled up open collector bus, except that it's implemented as a differential pair (usually). The terminating resistors not only terminate the transmission line, but also act as the pullup resistor. In the differential CAN implementation, they are really pull-together resistors, but logically have the same function as a pullup on a single ended open-collector bus.

Note that the CAN standard does not specify the actual physical bus. For short distances on the same board at the right bit rates, you can implement can as a single-ended passively pulled up bus. Unless you are doing something special, using two CAN transceiver chips to go between only two nodes 3 inches apart on the same board is gross overkill and a waste of money, power, space, and parts.

\$\endgroup\$
1
  • \$\begingroup\$ The 3" bus was only for testing. It'll be longer once I've got the PICs working. \$\endgroup\$ Sep 12 '11 at 18:12

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.