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
- https://lastminuteengineers.com/esp32-can-bus-tutorial/
- https://www.nxp.com/docs/en/data-sheet/TJA1050.pdf
- What is CAN Bus & How to use CAN Interface with ESP32 and Arduino - CIRCUITSTATE Electronics
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