# For the CAN bus, is it OK to swap CANH and CANL lines?

Similar to question In a USB cable, is it OK to swap the D+ and D- wires?, is it okay if we interconnect CAN-H and CAN-L lines?

CAN is a differential protocol. Is it that dominant and recessive bits are nothing but voltage differences on these lines?

Information about other differential protocols would also be useful.

• I think there would be two differences: H/L priority swap, and the data gets bitwise inverted. But I don't know enough about CAN to answer confidently. – travisbartley Jun 19 '13 at 6:15
• No. No. @trav1s No. Note that the voltage difference has a specified polarity, and that recessive means that there is no voltage difference. – starblue Jun 20 '13 at 19:43

I couldn't find any reference that gave a definitive answer. But looking at a few datasheets, I don't think so. USB is looking at the presence or absence of a change in voltage. Whereas CANBus is looking at the voltage itself.

Here is an example of a USB transmission:

The ones and zeros are coded depending on whether or not there is a transition.

As opposed to CANBus which takes the difference in the voltage levels as seen in this app note:

If we look at a datasheet for a CANBus transceiver, for example the MCP2551, we see something along the lines of:

  Sym                  Characteristic                   Min     Max  Units
VDIFF(r)(i)    Recessive differential input voltage    -1.0    +0.5    V
VDIFF(d)(i)    Dominant differential input voltage      0.9     5.0    V


Since a negative voltage is mentioned, this leads me to believe that polarity is important and they are not taking the absolute value of the differential voltage.

So if we have:

$$CANH = 2.5V$$ $$CANL = 2.5V$$

Normally the transceiver would do:

$$CANH - CANL = 2.5V - 2.5V = 0.0V = Recessive$$

If you swapped the lines it would do:

$$CANL - CANH = 2.5V - 2.5V = 0.0V = Recessive$$

So far so good. The problem comes when we have:

$$CANH = 3.5V$$ $$CANL = 1.5V$$

Here, the transceiver would normally do:

$$CANH - CANL = 3.5V - 1.5V = 2.0V = Dominant$$

If you swapped the lines it would do:

$$CANL - CANH = 1.5V - 3.5V = -2.0V = Recessive (out\ of\ spec)$$

So you the receiving end would see nothing but recessive bits.

• Aah... Interesting.... and and and 7 consecutive recessive bits is nothing but Error condition... How Intelligent specs designers are! :) – Swanand Jun 19 '13 at 17:50
• Doubt: Why -2V will be considered as Recessive?? – Swanand Jun 20 '13 at 9:48
• Doubt – Peter Mortensen Jun 20 '13 at 16:02
• @Swanand The datasheet for that particular chip says that voltages between -1.0V and +0.5V are recessive. As I noted above, the chip will probably see a voltage of -2.0V as a recessive bit even though it is out of spec. Though technically the value is indeterminate just like a voltage of 0.7V (inbetween recessive and dominant) and so it could be either. Operating electronics out of spec is Schrödinger's cat so it's best not to do it if you don't want a headache. – embedded.kyle Jun 20 '13 at 23:03
• @Swanand - 7 recessive bits is not an error condition, it happens all the time on an idle bus. And error frame is signified by dominant bits. – Martin Thompson Mar 7 '14 at 16:02

Swapping CAN-High and CAN-Low lines does not work. This is easy enough to establish empirically. I and my coworkers sometimes swap the lines by accident, and it is immediately apparent that it does not work.

• @embedded.kyle's answer explains why this happens. – Swanand Jun 20 '13 at 6:26

Everything depends on the transciver model. They is a certain flexibility on the value of CAN_H and CAN_L but I DO think that the value of CAN_H has to be higher in any case (at least for all the model that I have seen).

If you just change the cable pin, as soon as all the CAN_L are connected to each other and the CAN_H as well, it should work.