Hello
We are trying to connect the Seeed Can-bus shield v2.0 to our seeeduino lorawan. We can get it working on an arduino UNO without any problems, but not on the seeeduino.
We have regulated the SPI voltages from the can bus shield down tot 3.3 volt (confirmed with multimeter) and we have tried changing the spi clock (because the seeduino runs at 48Mhz) but we did not have any luck.
We have tried different CS-SS pins, we have tried the ICSP pins as well as the SPI pins located on D10-13.
As we understand the lora module uses pin D10 so we used pin D9 but that does not work either.
this is our current code. with the arduino it immediately said “Can bus shield init OK” but with the seeduino not.
[code]
// demo: CAN-BUS Shield, receive data with check mode
// send data coming to fast, such as less than 10ms, you can use this way
// loovee, 2014-6-13
#include <SPI.h>
#include “mcp_can.h”
//#include <LoRaWan.h>
// the cs pin of the version after v1.1 is default to D9
// v0.9b and v1.0 is default D10
const int SPI_CS_PIN = 9;
unsigned char len = 0;
unsigned char buf[8];
unsigned char flagRecv = 0;
MCP_CAN CAN(SPI_CS_PIN); // Set CS pin
void setup()
{
Serial.begin(115200);
Serial.println(“CAN BUS Shield init fail”);
while (CAN_OK != CAN.begin(CAN_500KBPS)) // init can bus : baudrate = 500k
{
Serial.println(“CAN BUS Shield init fail”);
Serial.println(" Init CAN BUS Shield again");
delay(500);
}
Serial.println(“CAN BUS Shield init ok!”);
attachInterrupt(0, MCP2515_ISR, FALLING); // start interrupt
CAN.init_Mask(0, 0, 0x7ff);
CAN.init_Mask(1, 0, 0x7ff);
CAN.init_Filt(0, 0, 0x240);
delay(1000);
}
void MCP2515_ISR()
{
flagRecv = 1;
}
void loop()
{
if (flagRecv)
{
flagRecv = 0;
CAN.readMsgBuf(&len, buf); // read data, len: data length, buf: data buf
unsigned long canId = CAN.getCanId();
Serial.println(canId);
Serial.print("<"); Serial.print(canId); Serial.print(",");
for (int i = 0; i < len; i++)
{
Serial.print(buf[i]); Serial.print(",");
}
Serial.print(">");
Serial.println();
}
}
[/code]
Does anyone have any other ideas to try, or know what we are missing?
Thanks in advance!