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

Exception initializing an RV3032 #1

Open
dizcza opened this issue Feb 6, 2024 · 2 comments
Open

Exception initializing an RV3032 #1

dizcza opened this issue Feb 6, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@dizcza
Copy link

dizcza commented Feb 6, 2024

I'm using your sketch to enable a 1Hz ClockOut wave in an RV3032 but rtc.init() fails with the following exception:

RTC Test
Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.

Core  1 register dump:
PC      : 0x400d1dd2  PS      : 0x00060830  A0      : 0x800d1f37  A1      : 0x3ffb2770  
A2      : 0x00000000  A3      : 0x00000051  A4      : 0x00000002  A5      : 0x00000100  
A6      : 0x00ff0000  A7      : 0xff000000  A8      : 0x800d25f8  A9      : 0x3ffb2750  
A10     : 0x3ffbdbc8  A11     : 0x3f403561  A12     : 0x00000002  A13     : 0xffffffff  
A14     : 0x3ffb8a28  A15     : 0x00000000  SAR     : 0x0000001c  EXCCAUSE: 0x0000001c  
EXCVADDR: 0x00000134  LBEG    : 0x400866c9  LEND    : 0x400866d9  LCOUNT  : 0xfffffffd  


Backtrace:0x400d1dcf:0x3ffb27700x400d1f34:0x3ffb2790 0x400d1268:0x3ffb27b0 0x400d1873:0x3ffb27d0 0x400d1699:0x3ffb27f0 0x400d2daa:0x3ffb2820 

Full sketch:

#include "RTC_RV3032.h"

RV3032 rtc;

static int64_t counter = 0;

static void IRAM_ATTR rtc_sqw_callback(void *args) {
    counter++;
}


void attach_rtc_sqw_tick_isr() {
    gpio_num_t irq_gpio = (gpio_num_t) 34;
    gpio_config_t irq_io_conf = {
            .pin_bit_mask = 1ULL << irq_gpio,
            .mode = GPIO_MODE_INPUT,
            .pull_up_en = GPIO_PULLUP_ENABLE,      // external pull-up
            .pull_down_en = GPIO_PULLDOWN_DISABLE,
            .intr_type = GPIO_INTR_NEGEDGE
    };
    ESP_ERROR_CHECK(gpio_config(&irq_io_conf));
    ESP_ERROR_CHECK(gpio_isr_handler_add(irq_gpio, rtc_sqw_callback, NULL));
    ESP_LOGI(TAG, "%s OK", __func__);
}


void setup() {
  Serial.begin(115200);
  while (!Serial);
  delay(500);
  Wire.begin(21, 22);
  Serial.println("RTC Test");
  rtc.init();
  Serial.println("RTC init OK");
  rtc.enable1Hz();

  ESP_ERROR_CHECK(gpio_install_isr_service(ESP_INTR_FLAG_IRAM | ESP_INTR_FLAG_LEVEL3));
  attach_rtc_sqw_tick_isr();
  
}

void loop() {
  delay(1000);
  Serial.printf("counter %d\n", counter);
}
@dizcza
Copy link
Author

dizcza commented Feb 6, 2024

Dear me, I had to call rtc.begin() prior to rtc.init() to initialize the class structure.
Now it works, thanks.

Please consider adding an API that specifies SDA and SCL pins as I'm using non-standard I2C pins and forced to modify your RTC::begin() function.

@dizcza dizcza closed this as completed Feb 6, 2024
@felias-fogg
Copy link
Owner

OK, I put it on my todo list

@felias-fogg felias-fogg reopened this Feb 6, 2024
@felias-fogg felias-fogg added the enhancement New feature or request label Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants