- Explore MCP Servers
- MCP251863
Mcp251863
What is Mcp251863
MCP251863 is an external CAN FD controller with an integrated high-speed transceiver from Microchip, designed for use with ESP32-based systems.
Use cases
Use cases include vehicle communication systems, industrial control systems, and any application where reliable CAN FD communication is essential.
How to use
To use MCP251863, integrate the driver library into your ESP32 project, configure the necessary parameters, and utilize the provided functions for communication and data management.
Key features
Key features include full FIFO management, acceptance filters, CRC-based SPI communication, ECC for RAM error correction, interrupt-driven concurrency support, bus-off detection, and advanced usage hooks.
Where to use
MCP251863 is ideal for applications requiring CAN FD communication, particularly in automotive, industrial automation, and IoT systems where additional CAN channels are needed.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Overview
What is Mcp251863
MCP251863 is an external CAN FD controller with an integrated high-speed transceiver from Microchip, designed for use with ESP32-based systems.
Use cases
Use cases include vehicle communication systems, industrial control systems, and any application where reliable CAN FD communication is essential.
How to use
To use MCP251863, integrate the driver library into your ESP32 project, configure the necessary parameters, and utilize the provided functions for communication and data management.
Key features
Key features include full FIFO management, acceptance filters, CRC-based SPI communication, ECC for RAM error correction, interrupt-driven concurrency support, bus-off detection, and advanced usage hooks.
Where to use
MCP251863 is ideal for applications requiring CAN FD communication, particularly in automotive, industrial automation, and IoT systems where additional CAN channels are needed.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Content
MCP251863 Production-Ready CAN FD Driver
A comprehensive driver for the MCP251863 chip (an external CAN FD controller + integrated transceiver from Microchip). This library is designed for production-level usage on ESP32-based systems (e.g., ESP32-DevKitC and ESP32-S3) running the Arduino framework, featuring:
- Full FIFO Management (TX, RX, TEF)
- Acceptance Filters (standard or extended)
- CRC-based SPI read/write for robust communications
- ECC for RAM error correction
- Interrupt-driven concurrency support (with FreeRTOS semaphores)
- Bus-Off Detection and re-initialization
- Bit Timing example for 500 kbits/s nominal + 2 Mbits/s data at 40 MHz
- Advanced usage hooks for TEF, acceptance filtering, error injection, etc.
Table of Contents
- Purpose
- Features
- Requirements
- Getting Started
- Usage
- Project / Library Architecture
- Configuration & Concurrency
- Supported Features
- Advanced Notes
- License
Purpose
The MCP251863 device combines a CAN FD controller with an on-board high-speed transceiver. It’s an ideal solution when your primary MCU (like the ESP32-S3) does not include a built-in CAN FD peripheral, or you need additional CAN FD channels.
This repository provides a robust implementation that covers almost all essential details for stable, production-grade operation:
- Reliable SPI usage with optional CRC verification
- Proper handling of the device’s 2 KB message RAM, including advanced features like ECC (Error Correction Code)
- Real-time concurrency and interrupt-driven approach for high-speed CAN FD up to 5 Mbps data phase
NOTE: Although this driver is quite complete, you must still test and tune it for your specific hardware setup, especially if you change bit timing, acceptance filters, concurrency, etc.
Features
- Multiple TX FIFOs (with configurable payloads up to 64 bytes)
- One or more RX FIFOs with optional timestamp capture
- Transmit Event FIFO (TEF) for TX completion tracking and timestamps
- Acceptance Filters (standard or extended ID)
- ECC (enable or disable) plus single/double-bit error detection
- CRC-based SPI commands (read/write)
- Bus-Off detection and auto-reinit
- Mode transitions: Configuration, Normal, Listen-Only, and Sleep
- Arduino (PlatformIO) / ESP-IDF friendly
Requirements
Hardware
- MCU: ESP32, ESP32-S3, or similar with SPI interface.
- MCP251863 or a pin-compatible device (MCP2517FD, MCP2518FD + ATA6563).
- CAN Bus with correct termination (120 Ω).
- Oscillator on MCP251863: typically 40 MHz for high bit rates.
Software
- PlatformIO or Arduino IDE with ESP32 board support.
- FreeRTOS semaphores (built into ESP32 Arduino) if you want concurrency.
- A working SPI bus on the pins you define (e.g. VSPI).
Getting Started
Install via PlatformIO
In your platformio.ini, reference dikibhuyan/[email protected] as a library dependency:
[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps =
dikibhuyan/[email protected]
Then the library will be automatically downloaded and included in your build.
Wiring
- Connect MCP251863 pins to your MCU SPI lines (SCK, MOSI, MISO, CS).
- Set STBY pin low for normal transceiver operation.
- (Optional) Hook up INT pin if you want interrupt-based reception.
Example main.cpp
#include <Arduino.h>
#include "MCP251863.h"
static const int CS_PIN = 5;
static const int INT_PIN = 4;
static const int STBY_PIN = 2;
MCP251863 canDriver(CS_PIN, INT_PIN, STBY_PIN);
void setup() {
Serial.begin(115200);
delay(1000);
Serial.println("MCP251863 Demo Start");
// For example, VSPI
SPI.begin(18,19,23,5);
// Initialize driver
auto st= canDriver.begin(SPI, 8000000);
if(st!=MCP251863_OK){
Serial.printf("Error init: %d\n", st);
while(1){ delay(1000); }
}
// 500k/2M at 40 MHz
canDriver.configureBitTiming(500000,2000000,40000000);
canDriver.setNormalMode();
Serial.println("CAN FD Ready");
}
void loop() {
// Periodic transmit
static uint32_t lastTx=0;
if(millis()-lastTx>1000){
lastTx=millis();
MCP251863_MSG tx={0};
tx.id=0x123;
tx.canFD=true;
tx.brs=true;
tx.dlc=8;
for(int i=0;i<8;i++){
tx.data[i]=i;
}
canDriver.transmitMessage(1,tx);
Serial.println("Sent message");
}
// Check for RX
MCP251863_MSG rx;
while(canDriver.receiveMessage(2,rx)==MCP251863_OK){
Serial.printf("RX: ID=0x%X, DLC=%d\n", rx.id, rx.dlc);
}
canDriver.service(); // check bus-off, ECC, etc.
delay(50);
}
Then pio run -t upload to build and flash.
Usage
Basic Polling
Use receiveMessage() in your loop to fetch frames from a RX FIFO. If you’re not under intense traffic, polling is often sufficient.
Interrupt-Driven
To enable higher throughput or real-time usage:
- Attach your
INTpin to an MCU GPIO. - Use
attachInterrupt(digitalPinToInterrupt(INT_PIN), onCANInterrupt, FALLING); - In the ISR, call
canDriver.handleInterrupt()or set a flag.
Inside handleInterrupt(), you can parse TEF, RX, or error flags, clearing them as needed.
Project / Library Architecture
A typical layout using this library via PlatformIO:
MyProject/ ├─ src/ │ └─ main.cpp (Your application code) ├─ platformio.ini └─ .pio/ ...
Where platformio.ini references dikibhuyan/[email protected] in lib_deps. The library and its MCP251863.cpp / MCP251863.h are automatically downloaded into .pio/libdeps/... by PlatformIO.
If you want to develop the library locally instead, you can place it in your project’s lib/MCP251863 folder with a library.json, then remove dikibhuyan/[email protected] from lib_deps.
Configuration & Concurrency
- Bit Timing
- This library shows an example for 500k/2M with a 40 MHz oscillator. Adjust
configureBitTiming()for your actual bus rates.
- This library shows an example for 500k/2M with a 40 MHz oscillator. Adjust
- Concurrency
- On ESP32, we use a FreeRTOS mutex for SPI calls (if present).
- On bare-metal or other MCUs, replace
mutexLock()with a critical section or do single-thread usage.
Supported Features
- CRC-based SPI read/write (optional).
- ECC for single-bit error correction, double-bit error detection.
- Acceptance Filters for standard or extended IDs.
- TEF for TX event / timestamps.
- Multiple TX/RX FIFOs.
- Bus-Off auto-recovery in
service().
Advanced Notes
- 2 KB RAM limit for TX/RX FIFO definitions plus TEF.
- For FD bit rates > 2 Mbps, consider carefully adjusting TDC (
CiTDCregister). - Avoid heavy SPI calls in your ISR if traffic is high; prefer reading minimal flags, then queueing for a background task.
License
This project is licensed under the MIT License. See LICENSE for details.
Enjoy using the MCP251863 for your next CAN FD project—and remember to thoroughly test in your real hardware environment to ensure reliability. If you have questions, open an issue or submit a pull request!
Dev Tools Supporting MCP
The following are the main code editors that support the Model Context Protocol. Click the link to visit the official website for more information.










