# SPI read error with MCP2515

In an attempt to interface a motor controller, battery management system and maximum power point tracking device on a CAN bus, I used the MCP2515 and TJA1050 CAN breakout board. All these devices send out CAN messages at the same bit rates. When interfacing with the motor controller, the messages were properly interpreted by Arduino. However, with both the other devices, there is an issue with the SPI read function. I am using the Seeed library, the documentation for which can be found here: https://github.com/Seeed-Studio/CAN_BUS_Shield/blob/master/mcp_can.cpp

The following function returns the code that suggests that there is no message. The readStatus condition fails.

byte MCP_CAN::checkReceive(void)
{
byte res;
res = mcp2515_readStatus()              // RXnIF in Bit 1 and 0
}


The readStatus function is as follows:

byte MCP_CAN::mcp2515_readStatus(void)
{
byte i;
#ifdef SPI_HAS_TRANSACTION
SPI_BEGIN();
#endif
MCP2515_SELECT();
MCP2515_UNSELECT();
#ifdef SPI_HAS_TRANSACTION
SPI_END();
#endif

return i;
}


The i value returns a 0. Each of the devices has a termination resistor, so a 100 ohm resistor was added at the CAN module end. The voltages were measured with respect to CAN ground, around 2.7 and 2.1 on CANH and CANL lines respectively.

• Were the voltages measured with a multimeter? – Peter Mortensen Aug 6 '18 at 17:37
• Yes, but I also used an oscilloscope to see the waveform. – Khalidos Aug 6 '18 at 17:39
• Re "All these devices send out CAN messages at different bit rates" Don't you mean they send out CAN messages at different rates at the same bit rate? – Peter Mortensen Aug 6 '18 at 17:40
• The idea to try each device alone on a bus strikes me as rather obvious – Maple Aug 6 '18 at 23:58
• "All these devices send out CAN messages at different bit rates" You can't have several different bit rates on the same bus. – Lundin Aug 7 '18 at 9:49