1
\$\begingroup\$

I have been trying to design a functional board which combines the hardware of the Elecrow Arduino Uno CAN bus shield with a microcontroller board, which functions like an Arduino except with different hardware. This design can be programmed, with the appropriate software drivers for the Arduino IDE, but it skips over all of the CAN stuff.

This picture shows the connections between the PIC32 and the MCP2515 CAN controller.

Schematic diagram

Ignore everything in the image except the connections that exist between the CAN controller and the PIC32. I have probed some of the serial lines between the two chips and found that there is no clock signal. As such, there is no way the SPI module can be working, except how does the Arduino code run?

void setup()
{
  Serial.begin(115200);
  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!");
}

Above is just a snippet of the code used to initialize the CAN bus in the Arduino IDE. When the CS bit is set to anything other than 10, the program will just loop through the while loop, wherein it complains that the CAN bus has failed to initialize. In the alternative case, it will simply skip over all the CAN commands as if they weren't in the code and everything else in the program runs fine.

So as mentioned, I found there was no serial communication between this chip and the controller. In fact, the program switches on globes connected to FET switch circuits when it senses ground at the analog ports. When this occurs, there is a sudden random surge on the clock line, but how can this be possible unless the chip is broken? I said to somebody before that if the SPI module was damaged, wouldn't the entire chip not work? Please note that the text "CAN bus init OK!" does not appear in the serial monitor, when the PCB is connected via USB.

My next line of reasoning was that perhaps I needed to change the baud rate to match that of the SPI module of the PIC32. It doesn't matter what I change it to, the CAN bus does not initialize. Another engineer looked at the design and noticed that by connecting the MCP2515 to 5 V would cause the crossover voltage on the ports to have a VIH too high for the chip to function. This pin was disconnected and connected to 3.3 V which should fix part of the problems I was having, but this serial communications problem remains unsolved.

If anyone has any useful hints or experience in this area and could shed some light on it, I'd appreciate it greatly.

\$\endgroup\$
  • \$\begingroup\$ What is CAN.begin(CAN_500KBPS)? \$\endgroup\$ – Jeroen3 Dec 17 '18 at 7:26
  • 2
    \$\begingroup\$ Using external CAN controllers is a thing of the past. This is how we designed CAN 20 years ago. Is there a reason why you picked such a painful route, instead of picking a MCU from this millennium with CAN controller on-chip? \$\endgroup\$ – Lundin Dec 17 '18 at 8:01
1
\$\begingroup\$

You should have something more in the line of the following.

if(CAN0.begin(MCP_ANY, CAN_500KBPS, MCP_16MHZ) == CAN_OK)

Surely you should also set up your interrupt pins and your SPI connection to the MCP2515.

\$\endgroup\$
  • 1
    \$\begingroup\$ I'll give it a shot. \$\endgroup\$ – burton01 Jan 8 at 22:55

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.