Pin Mapping and limitations of the MCP2515 library in Simulink
13 views (last 30 days)
Since revision 2019b, MCP2515 is supported as a library in Simulink. My questions are related to this library.
For me coming from an Arduino background I'm used to designing my own shields. Sometimes I'm therefore using other pins for interrupt and chip select, based on certain design criterias for that particular shield. From what I can read in the documentation about these libraries, the pin mappings are restricted to a few certain pins. To me that seems as a quite severe limitation that doesn't really give any proper advantage. Some of my shields also use more than one CAN channel, i.e. multiple MCP2515:s. It seems as the libraries are restricted to use only one channel. I'm sure that you are aware of this but it is not at all uncommon with nodes that are present on several CAN buses, for example powertrain and chassi-can.
My questions are therefore:
Question 1: Is there any possiblity of unlocking the pin mapping so that the Interrupt and Chip Select pins can be used more freely?
Question 2: Would it be possible to add support for more than one Can-bus using the MCP2515 library?
Arun Kumar on 5 Oct 2020
I've answered your questions below.
Possibility of Unlocking pins:
There's only one restriction for SPI chip select pin. You can select any pin that is exposed on Arduino header to act as SPI Chip select. The only restriction being - it should not be SPI pin(SPI Clock, SPI MISO, or SPI MOSI).
Currently, we don't support pins that are not exposed on Arduino header. If you intend to use those pins, please let us know. We can consider adding support for them in future releases.
Interrupt Pin: This pin needs to be a pin that has interrupt capability. On AVR targets, these pins are limited but for Arm targets, there are plenty of options to choose from.
Support for more than one CAN channel:
Since the communication with the CAN chip is happening over SPI, there are some limitations when it comes to communicating with multiple CAN chip over SPI. We'll consider this for future releases though.
Thanks a lot for your feedback.