I made my own PCB with ATmega4808 (32pin, with MegaCoreX) and connected to it a CAN bus module based on MCP2515 & TJA1050. I connected it to the SPI2 (pins PC0, PC1, PC2). Now I’m having problems communicating with it.
I’m using the arduino-CAN library by Sandeep Mistry GitHub - sandeepmistry/arduino-CAN: An Arduino library for sending and receiving data using CAN bus. (I used it in the past with an UNO with no problems).
I could not figure out how to tell the code to use the second SPI bus.
I’m Using the library "CANReciver.ino" example.
I tried to add to the setup()
SPI.setMOSI(PIN_PC0);
SPI.setMISO(PIN_PC1);
SPI.setSCLK(PIN_PC2);
Or
SPIClass SPI_2(PIN_PC0, PIN_PC1, PIN_PC2);
But they both don’t compile.
What is the correct way to let the library use the SPI2 for the CAN module and not the default SPI1?