ESP32 Continuous Reboot - CAN line

Hey guys.

So I have been attempting to use 2 different esp32 dev boards and CAN communication boards (link below) using the TJA1050 chip to work on some CAN communication between board to eventually use in a different project but have caught a snag.

The main issue that I have encountered the esp32 continuously resetting and getting this error message repeating:

rst:0x8 (TG1WDT_SYS_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1344
load:0x40078000,len:13936
load:0x40080400,len:3600
entry 0x400805f0
CAN Sender

I have checked many forms to attempt to fix it and this is what I have tried/what I know:

  • Disconnect all wires from the board and just upload the code that has caused the error (did not work)
  • Change the Flash Frequency From 80mHz to 40 mHz
  • Use different CAN libraries and codes that were provided by the libraries
  • Included line like this to stop the issue
    #include "soc/soc.h"
    #include "soc/rtc_cntl_reg.h"
    WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); //get error with this line
  • Attempted to use an earlier version of the 'ESP32 Dev Module' Versions used include 3.0.3 (latest), 2.0.17, and 2.0.10
  • The main libraries I have used have been:
    arduino-CAN-master - gith ub.c om/sandeepmistry/arduino-CAN (broken up to keep link)
    ESP32-Arduino-CAN-master - gith ub.c om/miwagner/ESP32-Arduino-CAN (broken up to keep link)

Stuff that has worked:

  • Blink
  • Having the serial monitor count up (prove that simple script doesn't brown out)
  • commenting out a specific section of the CAN library test code
  • RFID test code
  • Simple Button and lights

Sources Use

List item
CAN device Used - Amazon.com: Comimark 5Pcs CAN Bus Module Transceiver TJA1050 Controller Schnittstelle Board for Arduino : Electronics

Code that I would like to use but is not working. There is also commented section that is mentioned above that allows the code to get to the void loop:

#include <CAN.h>

#define TX_GPIO_NUM   10  // Connects to CTX
#define RX_GPIO_NUM   9  // Connects to CRX

void setup() {
  Serial.begin (115200);
  while (!Serial);
  delay (1000);

  Serial.println ("CAN Sender/Sender");

  // Set the pins
  CAN.setPins (RX_GPIO_NUM, TX_GPIO_NUM);
  CAN.begin (500E3);

  // start the CAN bus at 500 kbps 
  //////////////////////////////////////////////////////////////////////////////////////////////////////////
  ////// Commenting out this section allows the code to get the the void loop and print 'Here'
 //////////////////////////////////////////////////////////////////////////////////////////////////////////
  if (!CAN.begin (115200)) {
    Serial.println ("Starting CAN failed!");
    while (1);
  }
  else {
    Serial.println ("CAN Initialized");
  }
//////////////////////////section end/////////////////////////////////////////////////////
}

void loop() {
  Serial.println("Here");
  delay(1000);
  canSender();
  //canReceiver();
}

void canSender() {
  // send packet: id is 11 bits, packet can contain up to 8 bytes of data
  Serial.print ("Sending packet ... ");

  CAN.beginPacket (0x12);  //sets the ID and clears the transmit buffer
  // CAN.beginExtendedPacket(0xabcdef);
  CAN.write ('1'); //write data to buffer. data is not sent until endPacket() is called.
  CAN.write ('2');
  CAN.write ('3');
  CAN.write ('4');
  CAN.write ('5');
  CAN.write ('6');
  CAN.write ('7');
  CAN.write ('8');
  CAN.endPacket();

  //RTR packet with a requested data length
  CAN.beginPacket (0x12, 3, true);
  CAN.endPacket();

  Serial.println ("done");

  delay (1000);
}


void canReceiver() {
  // try to parse packet
  int packetSize = CAN.parsePacket();

  if (packetSize) {
    // received a packet
    Serial.print ("Received ");

    if (CAN.packetExtended()) {
      Serial.print ("extended ");
    }

    if (CAN.packetRtr()) {
      // Remote transmission request, packet contains no data
      Serial.print ("RTR ");
    }

    Serial.print ("packet with id 0x");
    Serial.print (CAN.packetId(), HEX);

    if (CAN.packetRtr()) {
      Serial.print (" and requested length ");
      Serial.println (CAN.packetDlc());
    } else {
      Serial.print (" and length ");
      Serial.println (packetSize);

      // only print packet data for non-RTR packets
      while (CAN.available()) {
        Serial.print ((char) CAN.read());
      }
      Serial.println();
    }

    Serial.println();
  }
}

Over all I am very confused and do not know where to go with this at this point. I am not sure if this is a hardware or software issue but I do suspect it is a software because the board still works.

If there are any suggestions I would very much appreciate it. Thank you

P.S.
Also to note I am new to using ESP32 chips however not new to micro controllers or coding. I do know there are some pins that have some oddities to them however they are not being used

Post links to the particular ESP32 boards you have used.
Today there are many versions of the ESP32 and not all libraries have been updated for the newer versions.

Also the TJA1050 isn't the right choice for the 3.3v ESP32.
Try the TJA1051T/3 or SN65HVD230D.

Here is the link to the esp32 Board

Not sure about those. The vast majority of original ESP32 boards were fitted with micro USB ports and it's unusual to see USB-C on an old style board.

If it is an original old style ESP32 then try this library without anything connected to the CAN pins.

It should at least run without crashing, even though you won't be able to send or receive data.

Hi, I was wondering if you ever got to the bottom of this? I have the same issue trying to using a TJA1050 can device.

Martin

I have not. Since mikb55 's post I have not been able to work on the project. I was tasked with a few other things that were more pressing. The current plan is to continue working and trying the library on Monday 8/19

as well I am going to try these CAN chips to see if there is anything different

If/When there is progress I will make sure to report it

the ESP32 has a builtin Canbus interface - see Two-Wire Automotive Interface (TWAI)
just requires an external CAN transciver - see what-is-can-bus-how-to-use-can-interface-with-esp32-and-arduino
also see ESP32-TWAI-CAN library

Hi, many thanks for the replies. I have a confession to make! Being old, with failing eye sight, I found that I had the ground side of the TJA1050 device connected to the ESP32 CMD pin and not GND pin! Once I realised that,the rebooting stopped! I do apologize for taking up you time.

Martin

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.