The intent is to use the DS1307 1Hz SQ as interrupt on the ESP32. Using the DS1307RTC.h and wire.h libraries via PlatformIO. In different sketches, I am able to read the date/time from the RTC, or to create the 1Hz square wave. However, once I merge, the ESP32 crashes. It seems to be clash of the RTC.read and the Wire related I2C commands.
I can not find much on Internet about this combined use. Any help that can be offered?
Hi.
I’m also not familiar with that specific problem.
Do you have more information? Do you get any errors on the Serial Monitor when the ESP32 crashes?
Regards,
Sara
Hi Sara, many thanks for the reaction. It is not clear to me whether this is an ESP32 hardware issue, a library issue, or a coding issue on my side.
here a complete description:
Description
When using the library for the square wave generation or for a RTC.read (in different sketches) they work fine, however, when combined in a sketch, it crashes the ESP32 and cause unlimited re-boots.
Hardware & Software
Hardware: ESP32-WROOM-32, Elegoo DS1307 module v3, led and pullup resistor of 5k1 on GPIO 5. SQA output of the DS1307 to GPIO 32 as interrupt.
Use of PlatformIO
Arduino Sketch
// sketch is kept in simplest form so as only to confirm the working of the square wave generation and the RTC.read instruction. Sketch will work as written below. Undo comments around RTC if-loop to cause the reboot situation
#include <Arduino.h>
#include <DS1307RTC.h>
#include <Wire.h>
#define DS1307_CTRL_ID 0x68 // DS1307 I2C device address 0x68
#define ledPin 5 // LED via pullup on GPIO 5
#define interruptPin 32 // output of SQA on DS1307 conneceted to GPIO 32
tmElements_t tm;
void setSQW(byte location, byte value) {
Wire.beginTransmission(DS1307_CTRL_ID);
Wire.write(location);
Wire.write(value);
Wire.endTransmission();
}
void IRAM_ATTR handleInt() {
digitalWrite(ledPin, !digitalRead(ledPin));
}
void setup() {
Serial.begin(115200);
while (!Serial) ; // wait for serial
delay(200);
Serial.println(“DS1307RTC Set SQW 1 Hz”);
pinMode(ledPin,OUTPUT);
pinMode(interruptPin, INPUT);
// GPIO 32
attachInterrupt(digitalPinToInterrupt(interruptPin),handleInt,FALLING);
// set SQ to 1 Hz
setSQW(0X07, B00010000);
}
void loop() {
/*
if (RTC.read(tm)) {
Serial.print(“Time available”);
};
*/
delay(1000);
}
Crash/reboot information
Rebooting…
ets Jun 8 2016 00:22:57
rst:0xc (SW_CPU_RESET),boot:0x12 (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:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:10124
load:0x40080400,len:5828
entry 0x400806a8
Guru Meditation Error: Core 0 panic’ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x400d0ef9 PS : 0x00060930 A0 : 0x800d10be A1 : 0x3ffe3b50
A2 : 0x3ffbffe8 A3 : 0x00000000 A4 : 0x00000000 A5 : 0x00000000
A6 : 0x00ff0000 A7 : 0xff000000 A8 : 0x800d0eee A9 : 0x3ffe3b20
A10 : 0x3ffbffe8 A11 : 0x3ffbdc54 A12 : 0x00000000 A13 : 0x00000000
A14 : 0x00000000 A15 : 0x3ffbdc54 SAR : 0x00000020 EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000020 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0xffffffff
ELF file SHA256: 0000000000000000
Backtrace: 0x400d0ef9:0x3ffe3b50 0x400d10bb:0x3ffe3b70 0x400d10c6:0x3ffe3b90 0x400e29eb:0x3ffe3bb0 0x400827e5:0x3ffe3bd0 0x400829e5:0x3ffe3c20 0x40079247:0x3ffe3c40 0x400792ad:0x3ffe3c70 0x400792b8:0x3ffe3ca0 0x40079465:0x3ffe3cc0 0x400806da:0x3ffe3df0 0x40007c31:0x3ffe3eb0 0x4000073d:0x3ffe3f20
Hi.
I’m not sure exactly what might be causing the issue. But I think it is some compatibilities between the interrupt and the other part of the code.
Try using a different GPIO for the interrupt and see if that changes anything. I would also try to use another GPIO for the LED, just in case… Just to test if everything is fine with the GPIOs…
I would also try changing the handleInt function to something even simpler…
I hope this helps.
Regards,
Sara
dear Sara, I found the problem. The code works if compiled and uploaded via Arduino IDE2, but not via PlatformIO.
This presents an issue for I had changed to PlatformIO as Arduino IDE2 does not yet allow html, css, and js files to be uploaded via SPIFFS. I guess I will find a work-around….if only by going back to Arduino IDE1
In any case, many thanks for the suggestions and patience,
Paul
That’s not supposed to happen.
The code should work regardless of the platform used.
Double-check if you have all the libraries updated on PlatformIO as well as the ESP32 boards.
Regards,
Sara
Hi Sara,
I created a new PlatformIO project, installed libraries to it, and copied the code from Arduino back into the new project. Problem remains the same.
That’s a very unusual behavior.That never happened to me before.
The only things that I can see that might be causing the issues are the versions of the libraries of the version of the ESP32-arduino framework…. but I’m not sure if there are other incompatibilities that might cause the issue.
I’m sorry that I cannot help much.
Let me know if meanwhile you find something.
Regards,
Sara