Seeed Can bus sheild Init failure with authentic Uno R3


I had a project a while back involving 3 canbus nodes. It worked fine and ran for days. However, I do vaguely remember having initial difficulties getting working libraries. At some point, my house was broken into and that laptop was stolen, got busy at work, and became involved in other projects. But now, I'm interested in the CAN project again, so I pulled from git and got things compiled. I am using Seeed Can-bus-shield 'lib' -- the latest zip available on github.

Problem is, only one of the nodes actually initializes. At first, I though it was a difference between the seeed card versions (i have both v1.2 and v2 cards), but then I noticed that the node which worked was using a Uno knockoff-card. That knockoff uno will initialize okay with either seeed card (v1.2 or V2); neither seeed shield will work with other authentic Uno R3's.

The knockoff is using a 12MHz oscillator, compared to the normal 16 on UNO.

I've configured/tried seeed cards to use SPI_CS of 9 and 10. Same result. Fail to init.

To give you an idea of the code -- I am able to create the issue using the standard send.ino from the Seeed lib's example folder. No modifications.

MCP_CAN CAN(SPI_CS_PIN)   // tried 9 and 10  (10 with cut/solder mod)

void setup()


  while (CAN_OK != CAN.begin(CAN_500KBPS))              
    // 100% fails -- never breaks out of loop.  


I added some printf profiling to mcp_can.cpp, trying to figure out where CAN.begin was yaking. The callstack is:

MCP_CAN::begin(byte speedset, const byte clockset)

  • mcp2515_init(speedset, clockset)
    -- mcp2515_reset()
    -- mcp2515_setCANCTRL_Mode(MODE_CONFIG)

The failures occur within setCANCTROL_Mode. Here's the printf version, functionality the same:

byte MCP_CAN::mcp2515_setCANCTRL_Mode(const byte newmode)

    mcp2515_modifyRegister(MCP_CANCTRL, MODE_MASK, newmode);

    byte val = mcp2515_readRegister(MCP_CANCTRL);
    byte i = val & MODE_MASK;

// newmode == 0x80, in this case
// MODE_MASK is 0xE0 (so we don't seem to care about 5 lsb in readReg)
// on the Uno R3, readRegister always returns 0 --> Fail;  (newmode) 0x80 != 0
// on the 12MHz knockoff arduino, x87 is returned --> Okay; 0x80 == 0x87 & 0xE0

  #ifdef DEBUG_EN
    Serial.print( "BO: in setCANCTRL_Mode:  newmode:");
    Serial.print( newmode, HEX );
    Serial.print( " , val: ");
    Serial.print( val, HEX ); 
    Serial.print( " , masked: ");
    Serial.print( i, HEX ); 

    if ( i == newmode )
      return MCP2515_OK;

    return MCP2515_FAIL;

So, I'm several hours of lost here. Any ideas? I don't know much about SPI, but it is configured by mcp_can.cpp. It's like SPI is not working at all, not read/writing to the mcp2551/2515.

I also tried Fowler's lib quickly just now -- the Loopback sample fails on Init too -- but I have not dug under covers. I suspect that it's the same, since he forked from Seeed, afaik.

I've tried Arduino installs for 1.6.8 and 1.8.something

thanks, O