# Is a CAN enabled microcontroller sufficient to drive a CAN bus?

There are a number of CAN modules built into microcontrollers these days. The PIC18F2480 is an example of that. Is that microcontroller (with built-in CAN) capable of driving a CAN bus on its own or is an external CAN transceiver/controller required?

I believe CAN has both a software and hardware layer and by the looks of it these CAN-enabled microcontrollers appear to have just the software, but it does not state that it can or cannot drive the CAN bus as is.

I'm looking to connect more than six microcontrollers through a CAN bus and would like to know if I need a transceiver across all of them or whether the built-in stuff can handle the communication from a software and hardware perspective.

Assume that I'll have necessary termination resistors and other small discrete components (caps, resistors, etc.)

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.

• Absolutely fantastic reply. I greatly appreciate the time you took to reply. I might have to go with the transceiver because there might be alot of electrical noise, and though everything will be housed in a "box" they will be on multiple pcbs. Thanks again! – efox29 Apr 24 '12 at 12:47
• @efox29 - You're welcome. It's certainly better to go with transceivers if you can. – Rocketmagnet Apr 24 '12 at 15:16
• That transceiverless setup was new to me and looks very interesting for setting up a simple network of controllers over longer distances. Nice! – 0x6d64 Jun 24 '12 at 13:48
• @0x6d64 - If you need it long, don't forget to use a low bit rate, and slew rate limit the edges. – Rocketmagnet Jun 24 '12 at 22:55
• Note that this will work if all the devices on the bus use the same configuration, and use a single-wire CAN bus. If you want to interface with anything else that is actually "real" ISO CAN and uses a two-wire bus, this mode won't work. – Jon Watte Jul 22 '17 at 5:40

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.

The LPC11Cxx family of microcontrollers (ARM Cortex-M0 based) include the CAN transceiver on-chip.

• Yes. Right. OP asks about PIC18. This isn't really helpful. – Federico Russo Apr 24 '12 at 14:15
• @FedericoRusso he gives an example with the PIC18, and timrorr has given a solution with built-in driver. What's wrong with that? – clabacchio Apr 24 '12 at 14:18
• @FedericoRusso - Don't be so anal. This answer is very interesting. – Rocketmagnet Jun 24 '12 at 13:21
• @Rocketmagnet: So Q: "How do I do X?" A: "Do Y." is OK after all? (From your own answer) – Federico Russo Jun 24 '12 at 14:28
• @FedericoRusso - If the question has been well answered to the OP's satisfaction, and someone mentions some interesting related information, sure, why not? – Rocketmagnet Jun 24 '12 at 15:46

You need a CAN transceiver chip between the CPU and the CAN bus. Check out the MCP2551.

## Update 17 Aug 2017:

I'm at the Microchip Masters conference right now. I was told flat out by Microchip engineers that one of the new parts that resulted from the Atmel acquisition is both cheaper and better than the MCP2551.

• Microchip is recommending the 2561 over the 2551 now. NXP has also some interesting CAN chips. Most MCUs need a transceiver. – Ludwig Schreier Dec 16 '16 at 22:16

Analog devices has an example CAN transceiver circuit using a differential amplifier.
I haven't tried this, am just aware of it. Also interested if it could be implemented with an op-amp

The advantages of using dedicated IC CAN transceiver is they will handle arbitration for you and you don't have to worry about interfering with the bus. If you are only observing the bus and it's not a fault critical environment, the circuit may be fine. While the mcp2551 is very popular, there are many options for interface chips.

A new evolution are the System Base type of chips which include voltage regulation, power modes, and ESD protection from the bus.

Like timorr said above, NXP's LCP11C24 is unique in that the processor includes CAN transceiver. A demo board with this is only $19. Another low cost solution is to use the$9.38 Cypress PSoC5 demo board, the CY8CKIT-059. The PSoC5 doesn't have a CAN controller; it goes one further: the controller is implemented in the FPGA-like universal blocks. The controller's registers are configured via the IDE's GUI, making filtering and R&D pretty easy.

A key method I have found when perusing data sheets is the mcu TTL is labeled CAN-Tx and CAN-Rx while the transceivers' data lines to the bus are always labelled CAN-H and CAN-L. I dislike the diagrams in the other answer where TxRx are shown connected to the bus; this goes against convention and contributes to confusion.