Is a CAN enabled microcontroller sufficient to drive a CAN bus?
This is a very good question. As a general rule, CAN requires a transceiver for every node:
However, under certain circumstances, you can actually get away without any transceivers! Those circumstances are:
- Short bus length (much less than 1 meter)
- Preferably all microcontrollers are on the same PCB, or stack of PCBs.
- The bit rate is low
- The environment isn't too electrically noisy
These aren't hard rules. You might get away with maximum bit rate (1MB/s) if you have a really short bus (10cm).
To achieve this, you need to know a little about what the transceiver does. Like most transceivers, they can output a high or a low to the bus (representing 1 and 0), but the 0 can dominate a 1. I.E. If two transceivers try to speak at the same time, and one is saying 1 and the other is saying 0, then the 0 will win. We can re-create the same situation simply using diodes:
See the Seimens application note AP2921: On-Board Communication via CAN without Transceiver
But here's something even more interesting: The PIC actually has hardware support for transceiverless CAN!
You can configure the CAN TX pin so that is behaves in exactly the same way as the transceiver. This means you can wire up the CAN bus without the diodes. You'll still need the resistor though.
The LPC11Cxx family of microcontrollers (ARM Cortex-M0 based) include the CAN transceiver on-chip.
Yes, you need a tranceiver. The CAN pins on the micro are receive and transmit. The CAN bus itself uses a twisted-pair with differential signalling on two wires called HIGH and LOW.
One of the transceiver's jobs is to take the logic level you present on the TX pin an turn it into CAN bus signals:
- a logic '1' is represented by not driving the bus, so the HIGH and LOW lines "float" to 2.5V - called a "recessive bit" in CAN terminology.
- a logic '0' is represented by driving the HIGH line high and the LOW line low - called a "dominant bit" as it will override any recessive bits being transmitted.
The other is to take what is on the bus, and turn it back into a logic-level to send back from the RX pin to your micro.