the 0xFFs amount to “do nothing” instructions the
MCP2515 ignores. However, the two sets of eight clock
pulses from the MCU cause the MCP2515 to send the
RXB0SIDH and RXB0SIDL bytes into the MCU. HiAddr
stores the RXB0SIDH (0x24) value and LoAddr stores the
RXB0SIDL (0x60) value.
The function finally manipulates the bits and returns a
hex value to the calling program. Remember, the SIDH
and SIDL registers save bits in an “offset” manner.
Addresses in filter and mask registers use the same bit
Update Your Address
You might ask, “Okay, the MCP2515 pointed to the
SIDH register, so how does it get data from the SIDL
register, too? There’s no command to point to that
register.” After the MCU points to a register and performs
a read or write operation, the CAN-controller
automatically increments the address to point to the next
sequential register. If you must read bytes from, say, all the
RXB0 registers, you don’t need to address each
individually. Just start with the SIDH register and continue
to send 0xFF do-nothing instructions.
Each time you do, the MCP2515 will
continue to send the MCU all the
register bytes in order: RXB0SIDH,
...SIDL, ...EID8, ...EID0, ...DCL, ...D0,
and so on. You could create a loop
to read all 13 registers and save their
values in an array for later use. In the
MCP2515JT.cpp file, you will see
several such loops. After you retrieve
data bytes, use them as you wish.
The MCP2515JT.cpp file includes
the functions setMask_0 and
setMask_1 that set the receiver
masks (RXM0 and RXM1). It also
includes six new functions
(setFilter_0 through setFilter_ 5) that
let you put values in mask or filter
registers. These functions take a hex
value between 0x000 and 0x3FF (0
You can experiment with these
registers to see how they affect
receipt of data with different
addresses from the transmitter. Note:
Software can change filter or mask
information only when you put the
MCP2515 in its Configuration mode.
For an example that demonstrates
CAN-filter operation, see
CANJT3.cpp and try it. The listing
In the final article about the
MCP2515, you’ll learn about lags
and interrupts, how to interpret bits
on the CAN bus, and why other
CAN devices must acknowledge
receipt of messages. NV
44 February 2017
ELEC TRONI CS
www.allelectronics.com Order Toll Free 1-800-826-5432
Wi-Fi MODULE, ESP8266MOD
WITH INTEGRATED AMP
A self contained WiFi module
capable of either hosting an
application or offloading all
Wi-Fi networking functions
from another application processor.
Pre-programmed with an AT command set
Shower." 24" square,
flat-panel speaker with
an integrated amplifier.
Highly directional sound
pattern provides a targeted
audio signal to a person
standing under it. Designed to fit a drop-ceiling grid, or suspend from ceiling or wall.
23. 6" x 23. 6" x 1.64".
MODULE FOR 16 X 2 LCDS
Arduino compatible controller
for 16 x 2 LCD modules.
Also has output for LED
backlight. 16-pin header
solders into LCD. 42 x 19 x 8mm pc board
(excluding header pins).
LED MOTION SENSOR LIGHT
Turns on when it senses movement
and turns off after 90 seconds.
3. 25" x 2.03" diameter. Uses three
AAA batteries (not included).
CAT# MSL-04 $595 each
4-CHANNEL RELAY MODULE
Uses data signals to
selectively switch four
5V relays, each
capable of handling
10A loads. Onboard
LED indicators light when
a relay is switched. Screw
terminals for relay outputs.
0.1" header for voltage and signal input.
75 x 55 x 18mm.
CAT# RLM- 4
40 X 60MM SINGLE HOLE
280 point multilayer epoxy
board. Double-sided with
CAT# SB- 36 $275 each
BOOK & PARTS KIT
of fun and illustrative
that teaches the fundamentals of electronics.
Color photos and illustrations. Projects are
designed to be breadboarded, taken apart
and reused. Includes 88 page manual,
solderless breadboard and all the parts
necessary for 40 projects.
CAT# KT- 40
180 flashes per minute.
100 for 40¢ each
Yoshito Onishi, Kyle Crockett, and
Patrick Cruce created the original
MCP2515 code, which I used and
modified. Thanks, guys, I appreciate