3

I've run into a case of 'In theory it works, but in reality'....

I'm using the CAN-BUS Shield V1.2 from Seeed studio. Many things are written in broken english, so I'm starting to wonder if I can trust all of the information. http://wiki.seeed.cc/CAN-BUS_Shield_V1.2/

The USB Host Shield is a discontinued official Arduino model. https://www.arduino.cc/en/Main/ArduinoUSBHostShield

(I would link to the libraries, but I am unable to post more than 2 links)

CAN-BUS Pins:

AREF
ICSP (SCK, MISO, MOSI)
P9 - CS (SS)
P2 - INT
NC
IOREF
RST
3.3V
5V
Vin

USB Host Pins:

ICSP (SCK, MISO, MOSI)
P10 - SS
P7 - GPX
P8 - INT (actually RES?)
P9 - RES (actually INT?)

The only conflict I see is Pin 9 (CS on CAN, RES on USB). This is where it gets hazy... While the documentation on the bottom of the USBHost page implies that Pin 9 is RES, in the code Pin 9 is actually INT.

So, assuming Pin 9 is actually INT, I re-routed it to Pin 45 on on the Mega and changed it in the UsbCore.h file:

//typedef MAX3421e<P10, P9> MAX3421E; // old
typedef MAX3421e<P10, P45> MAX3421E; // new

Here is a snippet of the code I am running:

#include <PS3BT.h>
#include <usbhub.h>

#ifdef dobogusinclude
#include <spi4teensy3.h>
#include <SPI.h>
#endif

#include <Bounce2.h>
#include <Time.h>
#include <TimeLib.h>
#include <SPI.h>
#include "mcp_can.h"

const int SPI_CS_PIN = 9;

MCP_CAN CAN(SPI_CS_PIN); // Set CS pin

void setup()
{
    Serial.begin(115200);

    // THIS WORKS
    if (Usb.Init() == -1) {
        Serial.print(F("\r\nOSC did not start"));
    }
    Serial.print(F("\r\nPS3 Bluetooth Library Started"));

    // THIS FAILS
    while (CAN_OK != CAN.begin(CAN_500KBPS))
    {
        Serial.println("CAN BUS Shield init fail");
        Serial.println(" Init CAN BUS Shield again");
        delay(100);
    }
    Serial.println("CAN BUS Shield init ok!");
}

The CAN-BUS Fails to init until I physically remove the USB Host Shield.

If I remove the CAN-BUS code, The USB Host Shield functions normally.

If I remove the USB Host code, the CAN-BUS Shield still DOES NOT init.

I tried to sift through the CAN-BUS init code a little, and I can only assume it's failing to communicate via SPI. What am I missing here?

1

I think that there is an hardware bug on the USB Master shield: IC3, the 3-state buffer which converts MISO to 5V, is always active... The enable pin of this 74LVC1G125 (pin 1) should be connected to the pin ss_3V3. Then you can stack this shield with another one.

| improve this answer | |
  • It definitely feels like a hardware bug! I haven't circled back to address this in a while - I'll respond after I try this fix. – wookie4747 Jan 26 '17 at 21:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.