The MCP2515 stand-alone CAN-Controller from Microchip has a SP-Interface (SPI) which is connected to an Atmel AVR. The basic circuit is shown in the following image. In this design an ATmega16 is driven by the internal R/C at 8MHz and generates a 4MHz clock for the MCP2515. The internal R/C my have to be tuned by using tools provided by Atmel. I've used several ATmega16 without tuning but loaded the 8MHz OSCCAL-value. In "real-world" applications an external XTAL should be used. Autobauding is a planned extension but not implemented yet. Additionally to the ATmega and the MCP2515 a Philips PCA82C250 CAN controller interface is used for driving the CAN-Bus
Click here for high-res png (82kB)
Two ATmega/MCP2515/PCA-combinations are connected to the bus and send/receive CAN messages either with extended or standard ID. In the example the LED connected to one of the ATmegas is turned on or off when receiving a specific CAN-Message. The other ATmega is connected to a PC via RS232 and the firmware offers a command-line interface.
Available Options in this "shell"
Picture of the Test-Setup
The software consists of three main modules: the MCP2515 low-level driver (mcp2515.c), the main-code with the Command-Line interface and the state-machine (main.c/terminal.c) and an interface-module ("abstraction layer" - can.c).
Download : Version 0.9 - Please respect the "artistic license".
A Controller-Area-Network-sniffer based on the schematic and software described in the previous section. ATmega16 and MCP2515 are driven by the same 16MHz crystal. The software sets the MCP2515 in "Listen-only"-Mode and all messages received by the CAN-interface are sent via AVR-UART to the serial-port of a PC. On the PC the CAN-messages get collected and ordered by CAN-ID with a Win32-application.
The test-setup consists of a Philips LPC2129-based board. The Philips ARM7TDMI-Controller has two CAN2.0B interfaces and the software on the ARM7 lets the controller exchange messages between this two interfaces. The AVR sniffer is connected to the "LPC-CAN-Bus" (red/black in the pictures below) and collects all messages
Pictures of the Sniffer Test-Setup (Click on Images to Enlarge)
The software (AVR-firmware and MS-Windows-application) is not yet available.
This is a library with all three Microchip MCP2515 package-variants for the PCB Layout-Software EAGLE (done with Eagle 4.13). This library has not been reviewed. No warranty!
Download: MCP2515-Lib (20040125)
Another Library is available on this page.
back to my AVR projects page
112779 hits since January 26, 2005
Last mod.: Wednesday, 24-Aug-2005 20:26:58 CEST