CAN/LIN/J2602 PICtail
™
(Plus)
DAUGHTER BOARD USER’S GUIDE
2011 Microchip Technology Inc.
DS70319B-page 21
Chapter 3. CAN/LIN/J2602 PICtail (Plus) Daughter Board
Tutorial Program
This chapter provides a brief description of the code that can be used with the
CAN/LIN/J2602 PICtail (Plus) Daughter Board. When connected to the PIC18 Explorer
Board, the code included with the board can be used. When the daughter board is con-
nected to the Explorer 16 Board, some examples available on Microchip’s web site
(www.microchip.com) can be used. Topics covered include:
• PIC18 Tutorial Overview
• dsPIC33F and PIC24H Tutorial Overview
3.1
PIC18 TUTORIAL OVERVIEW
The PIC18 tutorial in this chapter demonstrates the CAN module features of the
PIC18FXXK80 family in mode 1. When either the PIC18F46K80 PIM or PIC18F66K80
PIM is connected to the PIC18 Explorer Board, and is interfaced with the
CAN/LIN/J2602 PICtail (Plus) Daughter Board, the tutorial demonstrates how to trans-
mit and receive with the CAN module.
The PIC18 tutorial project,
ECAN_Daughterboard.mcp
, is written in C for MPLAB
C18. Make sure that the correct PIC18FXXK80 device is chosen for the project. This
tutorial program transmits data over the CAN bus when the RB0 push button is
pressed, and has three filters with three buffers to receive data sent over the CAN bus.
The project contains three files,
main.c
,
CAN.c
, and
CAN.h
. The
CAN.c
and
CAN.h
files contain the functions used for CAN communication. These files can be easily
ported to other projects if needed. The
main.c
file contains the code that handles the
CAN communication for this specific tutorial.
Specifically for this example, while running in mode 1, when a CAN message is
received that fits one of the three filters, 0x111, 0x444, and 0x0A0, the LEDs on PORTD
increment by one. When the push button on RB0 is pressed, a CAN message is trans-
mitted. To show that the device is working properly, the LED on RD7 is toggled contin-
uously at a constant rate.
To effectively demonstrate this tutorial, a device is needed to transmit and receive mes-
sages to and from the PIC18FXXK80. Any device capable of CAN communication can
be used, but a CAN bus analyzer is the simplest to use. Microchip has a CAN bus ana-
lyzer available for purchase on the web called the CAN bus Analyzer Tool
(APGDT002). This analyzer tool can query the CAN bus for all messages transmitted
and received. It can be connected to the DB9 connectors on the CAN/LIN/J2602 PICtail
(Plus) Daughter Board.