Because an MCP2515 operates outside an MCU, it can take less time to set up and use than some MCU’s built-in CAN controllers. The control registers, message buffers, and flags
prove easy to understand, and C-code clarity improves.
The MCP2515 18-pin DIP makes it simple to breadboard
and test a circuit, or you can use an MCP2515 module,
shield, or cape. Before you start to experiment with an
MCP2515 IC, download and print its datasheet (pages 1
through 68) which provides complete register descriptions,
diagrams, flow charts, and tables (see References).
An MCP2515 relies on Serial-Peripheral Interface (SPI)
signals, so almost any MCU meets the
interface requirements. The examples
in this article use an mbed board with
an NXP LPC1786 (ARM Cortex-M3)
MCU that includes an SPI port. In
addition to the three SPI signals
(MOSI, MISO, and CLOCK), an
MCP2515 needs a logic 0 chip select
signal (/CS) along with power and
ground. The internal bit rate clock
requires an external crystal.
An MCP2515 CAN-controller IC
comprises three transmitter buffers
(TXB0, TXB1, and TXB2) and two
receiver buffers (RXB0 and RXB1)
which are shown in Figure 1. Receiver
buffer 0 includes one acceptance
mask (RXM0) and two acceptance filters (RXF0 and RXF1).
Receiver buffer 1 includes one acceptance mask (RXM1)
and four acceptance filters (RXF2 through RXF5). These
masks and filters let you direct CAN messages to a
specific buffer where the MCU can read it. You might use
RXB0 for messages with a high priority address and RXB1
for other messages within an address range.
The three transmit buffers differ only by name. Each
can hold as many as eight bytes of data, and each has
associated control and status bits, as well as an interrupt.
The receiver and transmitter buffers have the same
organization (Figure 2) that comprises a control byte, two
In the first part of this series, you learned about the physical Controller Area
Network (CAN) bus, bus arbitration, device addresses, and address masks
and filters. Not all MCUs include a CAN controller and even those that do
can challenge experienced designers. In either case, an external Microchip
MCP2515 CAN controller IC can do the job, and you'll learn how to use it.
Take a CAN Bus
for a Spin
By Jon Titus KZ1G
Post comments on this article and find any associated files and/or
downloads at www.nutsvolts.com/magazine/article/
February 2017 39
Add a CAN
controller to an
MCU that lacks one.
FIGURE 1. Each receiver buffer (RXB0 and RXB1) has
its own set of masks and filters. Each transmitter buffer
has registers for an 11- or 29-bit ID, a byte count, and
as many as eight data bytes. For clarity, this diagram
does not include all CAN-controller circuits. (The 29-bit
address mode goes beyond the scope of this article.)