MCP2517FD, MCP2518FD and MCP251863 driver
  • C 95.7%
  • C++ 4.3%
Find a file
Emandhal cb6c1eaad1 Bit time calculator, critical fixes and CiA 601-3 alignment
- Fix data segment clamping using nominal limits (NTSEG) instead of data limits (DTSEG) — wrong max 128/256 instead of 16/32
 - Fix DTQBIT_MIN/MAX macros referencing nominal instead of data constants in header
 - Fix uint32 overflow in BRP search loop — rewrite error metric using actual bitrate comparison
 - Fix MaxBusLength unsigned wraparound when propagation budget < transceiver delay
 - Fix TDC SSP missing DSYNC: BRP * DTSEG1 -> BRP * (DSYNC + DTSEG1)
 - Align TDC with Linux: AUTO only for DBRP ≤ 2, DISABLED otherwise, TDCV always 0 in AUTO
 - Replace fixed 80% sample point with CiA 601-3 stepped targets (875/800/750‰) with automatic fallback when TSEG1 overflows
 - Add division-by-zero guards and unsigned underflow protections in statistics
[Thanks to mickeyl]
2026-03-10 21:00:58 +01:00
CRC Fix #14 symlinks 2024-02-19 18:15:09 +01:00
Docs Update documentation 2023-03-21 22:20:15 +01:00
Tests Bit time calculator, critical fixes and CiA 601-3 alignment 2026-03-10 21:00:58 +01:00
.gitignore Fix comments and variable names 2026-03-10 20:54:46 +01:00
Conf_MCP251XFD_Template.h Initial driver commit 2021-03-14 22:23:50 +01:00
ErrorsDef.h Fix #9 and #10 compilation issues 2023-11-22 18:57:27 +01:00
LICENSE.md Initial commit 2021-03-14 19:30:37 +01:00
MCP251XFD.c Bit time calculator, critical fixes and CiA 601-3 alignment 2026-03-10 21:00:58 +01:00
MCP251XFD.h Bit time calculator, critical fixes and CiA 601-3 alignment 2026-03-10 21:00:58 +01:00
README.md Add support of the MCP251863 2022-04-05 19:26:05 +02:00

MCP251XFD

MCP251XFD is a fully hardware independant Driver primarily aimed at embedded world

Presentation

This driver only takes care of configuration and check of the internal registers and the formatting of the communication with the device. That means it does not directly take care of the physical communication, there are functions interfaces to do that. By doing this, the driver can control a MCP2517FD through a I2C to SPI converter without any change, the transformation will be done in the interface functions. Each driver's functions need a device structure that indicate with which device it must threat and communicate. Each device can have its own configuration.

Feature

This driver has been designed to:

  • Be fully configurable (all features of the MCP2517FD, MCP2518FD and MCP251863 are managed)
  • Detect which one of the MCP2517FD or the MCP2518FD (MCP251863 have a MCP2518FD inside) is connected
  • Take care of the CRC communication or Safe write if configured for the device
  • Manage all Sleep modes
  • Have no limit of configuration except the ones imposed by the device
  • Manage devices completely independently
  • Have an automatic CAN bit time setting
  • Prevent all configuration errors

Usage

Installation

Get the sources

Get and add the 4 following files to your project

MCP251XFD.c
MCP251XFD.h
Conf_MCP251XFD_Template.h
ErrorsDef.h

Copy or rename the file Conf_MCP251XFD_Template.h to Conf_MCP251XFD.h... Et voila!

Others directories

Tests\ directory

The Tests folder contains an example of use on the SAMV71 Xplained Ultra board See the Main_Synchronous.c for the hardware setup.

Tests\UnitTest\ directory

The Tests\UnitTest folder contains unit test for Visual Studio 2017 and are not required.

Configuration

To set up one or more devices in the project, you must:

  • Configure the driver (Conf_MCP251XFD.h) which will be the same for all devices but modify only its behavior in the project
  • Create and define the configuration of as many device structures as there are devices to use
  • Create and define controller and CAN controller configuration for each device. Multiple devices can share the same configuration
  • Initialize the device with the configuration structure previously defined

All is explained in the MCP251XFD driver library guide

Driver usage

All is explained in the MCP251XFD driver library guide