Hi,
I am trying to make a device that communicates with a recuperator via CAN bus. I'm using ESP32 and a ready-made MCP2515+TJA1050 module ( module: https://sklep.avt.pl/pl/products/modul-can-bu...-mcp2515-can-spi-tja1050-arduino-174337.html) for this. On the desktop without CAN connection it looks like everything is working. At the output of the module I can see on the oscilloscope the CAN waveform. As soon as I connect the chip to CAN, the chip immediately crashes and does not pass initialisation. As if the program is waiting for something on the SPI. I tried with the 120 ohm terminator connected and disconnected. The recuperator and CAN is working because after connecting another device everything works fine.
The only thing I can think of is replacing the terminating resistor with a different one and/or different CAN speeds on my device and the recuperator, but the recuperator definitely works on 50kbit/s. I haven't changed the resistor yet. Has anyone encountered this problem? Am I setting the speed correctly in the software? Any suggestions?
I am using a ready-made library from Adafruit.
.
I am trying to make a device that communicates with a recuperator via CAN bus. I'm using ESP32 and a ready-made MCP2515+TJA1050 module ( module: https://sklep.avt.pl/pl/products/modul-can-bu...-mcp2515-can-spi-tja1050-arduino-174337.html) for this. On the desktop without CAN connection it looks like everything is working. At the output of the module I can see on the oscilloscope the CAN waveform. As soon as I connect the chip to CAN, the chip immediately crashes and does not pass initialisation. As if the program is waiting for something on the SPI. I tried with the 120 ohm terminator connected and disconnected. The recuperator and CAN is working because after connecting another device everything works fine.
The only thing I can think of is replacing the terminating resistor with a different one and/or different CAN speeds on my device and the recuperator, but the recuperator definitely works on 50kbit/s. I haven't changed the resistor yet. Has anyone encountered this problem? Am I setting the speed correctly in the software? Any suggestions?
I am using a ready-made library from Adafruit.
/*
* Adafruit MCP2515 FeatherWing CAN Sender Example
*/
#include <Adafruit_MCP2515.h>
#ifdef ESP8266
#define CS_PIN 2
#elif defined(ESP32) && !defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S2) && !defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S3)
#define CS_PIN 5
#elif defined(TEENSYDUINO)
#define CS_PIN 8
#elif defined(ARDUINO_STM32_FEATHER)
#define CS_PIN PC5
#elif defined(ARDUINO_NRF52832_FEATHER) /* BSP 0.6.5 and higher! */
#define CS_PIN 27
#elif defined(ARDUINO_MAX32620FTHR) || defined(ARDUINO_MAX32630FTHR)
#define CS_PIN P3_2
#elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040)
#define CS_PIN 7
#elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040_CAN)
#define CS_PIN PIN_CAN_CS
#elif defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_RASPBERRY_PI_PICO_W) // PiCowbell CAN Bus
#define CS_PIN 20
#else
// Anything else, defaults!
#define CS_PIN 5
#endif
// Set CAN bus baud rate
#define CAN_BAUDRATE (50E3)
Adafruit_MCP2515 mcp(CS_PIN);
void setup() {
Serial.begin(115200);
//while(!Serial) delay(10);
Serial.println("MCP2515 Sender test!");
if (!mcp.begin(CAN_BAUDRATE)) {
Serial.println("Error initializing MCP2515.");
while(1) delay(10);
}
Serial.println("MCP2515 chip found");
}
void loop() {
// send extended packet: id is 29 bits, packet can contain up to 8 bytes of data
Serial.print("Sending extended packet ... ");
Serial.print("a");
mcp.beginExtendedPacket(0x1F074051,8,false);
Serial.print("b");
mcp.write(0x00);
mcp.write(0x84);
mcp.write(0x15);
mcp.write(0x01);
mcp.write(0x01);
mcp.write(0x00);
mcp.write(0x00);
mcp.write(0x00);
mcp.endPacket();
Serial.print("1/2 ....");
mcp.beginExtendedPacket(0x1F074051,7,false);
mcp.write(0x81);
mcp.write(0x00);
mcp.write(0x01);
mcp.write(0x00);
mcp.write(0x00);
mcp.write(0x00);
mcp.write(0x02);
mcp.endPacket();
Serial.println("done");
delay(5000);
}