You need to log in to create posts and topics.

MCP2515 CAN Controller

I have started developing a custom MCP2515 CAN controller component for SimulIDE.

The goal is to provide an educational simulation component that can be used with Arduino or other microcontrollers through SPI, in order to help students understand how a CAN controller works internally.

Current features include:

  • SPI communication with CS, SCK, SI/MOSI and SO/MISO
  • MCP2515 register emulation
  • RESET, READ, WRITE and BIT MODIFY SPI commands
  • READ STATUS and RX STATUS support
  • TX and RX buffer handling
  • INT output, active low
  • Loopback mode simulation
  • Virtual CAN bus communication between two MCP2515 components using a Bus ID
  • CANH/CANL visual waveform generation
  • Standard 11-bit CAN frame generation
  • Bit stuffing
  • CRC-15 generation
  • Simplified ACK handling

I tested the component successfully with two simulated Arduino boards:
one Arduino sends CAN frames through its MCP2515, and another Arduino receives them through a second MCP2515. The CANH and CANL signals can also be observed on the SimulIDE oscilloscope.

This is still an educational implementation, not yet a full physical CAN bus simulation. The next possible improvements are:

  • real arbitration between multiple transmitters
  • more accurate ACK behavior
  • error frames
  • acceptance filters and masks
  • extended 29-bit identifiers
  • bus-off and error counter management

I am sharing the code so that others can test it, improve it, or help integrate it properly into SimulIDE.

I hope this post could you help.

 

Uploaded files:
nemka has reacted to this post.
nemka