This repository contains an example of mcp2518fd operation with the SPI interface to MCU ATSAMD21G17D. Mainly of this code is from Microchip's example.
- MCP2518FD-Data-Sheet-20006027A
- MCP25XXFD-CAN-FD-Controller-Module-Family-Reference-Manual-DS20005678E
- SAM_D21_DA1_Family_DataSheet_DS40001882F
- DSC60xxB-Ultra-Small-Ultra-Low-Power-MEMS-Oscillator-DS20006133A
- 公众号文章-CAN控制器MCP2518FD
- MPLAB® X IDE 5.45
- MPLAB® XC16 2.50
- MPLAB® Harmony Configurator (MHC) 3.6.1
- CMSIS 5.6.0
- SAMD21_DFP 3.3.98
- MCP2518FD CLICK (PID: MIKROE-3060)
- SAMD21 Curiosity Nano Evaluation Kit (Part Number: DM320119)
- Curiosity Nano Base for Click boards (Part Number: AC164162)
The test boards I do the test is as follow.
The following picture describe the interface of hardware and software.
The spi clk between ATSAMD21G17D and mcp25625 is 1MHz, spi mode is 0. All codes except the following files are generated by mhc.
- drv_canfdspi_register.h
- drv_canfdspi_defines.h
- drv_canfdspi_api.h
- drv_canfdspi_api.c
- canfd.h
- canfd.c
The ossicilator for mcp2518fd is 40M, and the bitrate of Normal CAN is 500Kbps, Data CAN is 2Mbps.
When run this example, MCU will transmit message formate like ID is from 0x300 to 0x30f, and DLC is 64 byte, but will just receive message with ID from 0x300 to 0x307. Test result is as follow.
Actually, this is one driver example for mcp2518fd, you could use these code for other MCU's use.