Hello! Been working with a single mcp2515 module board for a while and now I wanted to connect one more mcp2515 (to access both high speed & low speed can buses), so ordered another one from ebay, now tried to connect it and I had a headache when setting up two boards on a single arduino uno board. Old one mcp2515 board was used for high speed bus, it works, new board for low speed, this doesn't work, it's not receiving messages. Swapped cs pins, old board works with low speed bus, new board doesn't work with high speed. Measured continuity on the board with multimeter, no problems, soldered good. Now I tried simplest program to send and receive message in loopback mode and it's not receiving messages. This is the code:
#include <SPI.h>
#include <mcp2515.h>
MCP2515 mcp(7);
can_frame send, recv;
void interrrrupt();
void setup()
{
// Begin serial & spi
Serial.begin(115200);
SPI.begin();
// Init mcp
mcp.reset();
mcp.setBitrate(CAN_250KBPS, MCP_8MHZ);
mcp.setLoopbackMode();
// Check for errors
if(mcp.checkError()){
Serial.println("mcp initialization failed, halting!");
while(1);
}
// Init can frames
send.can_dlc = 8;
send.can_id = 0x81224433;
send.data[0] = 0x12;
send.data[1] = 0x23;
send.data[2] = 0x34;
send.data[3] = 0x45;
send.data[4] = 0x56;
send.data[5] = 0x67;
send.data[6] = 0x78;
send.data[7] = 0x89;
recv.can_dlc = 8;
Serial.println("Ready!");
}
uint32_t nextSend = 0;
void loop()
{
// Send message
uint32_t now = millis();
if(now > nextSend){
mcp.sendMessage(&send);
nextSend = now + 1000;
Serial.println("Message sent!");
}
// Read messages
if(mcp.readMessage(&recv) == MCP2515::ERROR_OK){
Serial.print("Received message: 0x");
Serial.print(recv.can_dlc, HEX);
Serial.println(", data:");
for(int i=0; i<8; i++){
Serial.print(recv.data[i], HEX);
Serial.print(" ");
}
Serial.println();
}
}
Tried changing cs pin, still nothing. Also tried interrupt based reading, interrupt function is never called. So there's couple question left, is that mcp2515 board with a defect? Is there anything else I can try, or just order another board?