Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DS1307 square wave generation and RTC.read crash ESP32 #21

Open
paulfeohrev opened this issue Nov 30, 2022 · 0 comments
Open

DS1307 square wave generation and RTC.read crash ESP32 #21

paulfeohrev opened this issue Nov 30, 2022 · 0 comments

Comments

@paulfeohrev
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant