CAN BUS Sheild V2.0 not initialising with Teensy 4.1
![userHead](https://dfimg.dfrobot.com/dfPortrait2.png)
I am trying to use the CAN BUS Sheild V2.0 https://wiki.dfrobot.com/CAN-BUS_Shield ... __DFR0370_ with a Teensy 4.1 https://www.pjrc.com/store/teensy41.html . I assumed that it would work fine, however I have not been able to get it to initialise.
I have tried running the code below taken from the DF Robots CAN library examples.
I currently have the GND, 3v3 and 5v pins of the teensy connected to the respective pins on the CAN shield. Then I have the CS, MOSI, MISO and SCK on the CAN shield pins (10, 11, 12 and 13) connected to the teensy’s CS, MOSI, MISO and SCK pins (10, 11, 12 and 13), the teensy uses the same pins for these as the Arduino Uno.
When trying this the serial output on the teensy just says “DFROBOT’s CAN BUS Shield init fail”. I have tried not connecting the 5v pin so everything runs at 3v3 and I’ve also tried level shifting all the SPI pins to 5v with a logic converter. Also tried the CS going to 9 on the CAN shield as it is listed as 9 in some documents. I have also tried having the power switch on the CAN sheild on and off. Any help would be greatly apreciated![:slight_smile:](//cdn.jsdelivr.net/emojione/assets/svg/1f642.svg)
I have tried running the code below taken from the DF Robots CAN library examples.
I currently have the GND, 3v3 and 5v pins of the teensy connected to the respective pins on the CAN shield. Then I have the CS, MOSI, MISO and SCK on the CAN shield pins (10, 11, 12 and 13) connected to the teensy’s CS, MOSI, MISO and SCK pins (10, 11, 12 and 13), the teensy uses the same pins for these as the Arduino Uno.
When trying this the serial output on the teensy just says “DFROBOT’s CAN BUS Shield init fail”. I have tried not connecting the 5v pin so everything runs at 3v3 and I’ve also tried level shifting all the SPI pins to 5v with a logic converter. Also tried the CS going to 9 on the CAN shield as it is listed as 9 in some documents. I have also tried having the power switch on the CAN sheild on and off. Any help would be greatly apreciated
Code: Select all
// demo: CAN-BUS Shield, send data
#include <df_can.h>
#include <SPI.h>
const int SPI_CS_PIN = 10;
MCPCAN CAN(SPI_CS_PIN); // Set CS pin
void setup()
{
Serial.begin(115200);
int count = 50; // the max numbers of initializint the CAN-BUS, if initialize failed first!.
do {
CAN.init(); //must initialize the Can interface here!
if(CAN_OK == CAN.begin(CAN_500KBPS)) // init can bus : baudrate = 500k
{
Serial.println("DFROBOT's CAN BUS Shield init ok!");
break;
}
else
{
Serial.println("DFROBOT's CAN BUS Shield init fail");
Serial.println("Please Init CAN BUS Shield again");
delay(100);
if (count <= 1)
Serial.println("Please give up trying!, trying is useless!");
}
}while(count--);
}
unsigned char data[8] = {'D', 'F', 'R', 'O', 'B', 'O', 'T', '!'};
void loop()
{
// send data: id = 0x06, standrad flame, data len = 8, data: data buf
CAN.sendMsgBuf(0x06, 0, 8, data);
delay(100); // send data per 100ms
}
![p.name](https://dfimg.dfrobot.com/data/DFR0370/6W4A4602.jpg)