Help with coding in esp_wake_deep_sleep()
Posted: Mon May 30, 2022 3:47 pm
HI,
This is my 1st post to the forum, and hope someone can give me some guidance.
I have a ESP32-c3-12 on a dev board from RF Solutions, and is simple C coding without any rtos , and need to make use of the deep_sleep feature for waking up to a GPIO Level, as this is a battery powered water meter pulse detector
There are 3 places where once the BUTTON1( GPIO_NUM_2) is pressed the esp_wake_deep_sleep function loads, it encounters illegal Instruction for the following 3 lines :
Going to deep sleep:ESP-ROM:esp32c3-api1-20210207
Build:Feb 7 2021
rst:0x5 (DSLEEP),boot:0xd (SPI_FAST_FLASH_BOOT)
STUB : Wake count 0
Guru Meditation Error: Core 0 panic'ed (Illegal instruction)
Here is the code i currently have for the esp_wake_deep_sleep()
Could anyone suggest how I implement these 3 lines in ROM style code.
Many Thanks
This is my 1st post to the forum, and hope someone can give me some guidance.
I have a ESP32-c3-12 on a dev board from RF Solutions, and is simple C coding without any rtos , and need to make use of the deep_sleep feature for waking up to a GPIO Level, as this is a battery powered water meter pulse detector
There are 3 places where once the BUTTON1( GPIO_NUM_2) is pressed the esp_wake_deep_sleep function loads, it encounters illegal Instruction for the following 3 lines :
Code: Select all
ds_wakeup_reason = esp_sleep_get_wakeup_cause()
esp_deep_sleep_enable_gpio_wakeup(1ULL << BUTTON1,ESP_GPIO_WAKEUP_GPIO_LOW);
esp_deep_sleep_enable_gpio_wakeup(1ULL << BUTTON1,ESP_GPIO_WAKEUP_GPIO_HIGH);
Build:Feb 7 2021
rst:0x5 (DSLEEP),boot:0xd (SPI_FAST_FLASH_BOOT)
STUB : Wake count 0
Guru Meditation Error: Core 0 panic'ed (Illegal instruction)
Here is the code i currently have for the esp_wake_deep_sleep()
Code: Select all
#define BUTTON1 GPIO_NUM_2
RTC_DATA_ATTR int bootCount = 0;
RTC_DATA_ATTR int Armed = 0;
RTC_DATA_ATTR int Water = 0;
RTC_DATA_ATTR int wake_deep_stub_count;
void RTC_IRAM_ATTR esp_wake_deep_sleep(void) {
esp_default_wake_deep_sleep();
static RTC_RODATA_ATTR const char fmt_str[] = "STUB : Wake count %d\n";
esp_rom_printf(fmt_str, wake_deep_stub_count++);
esp_sleep_wakeup_cause_t ds_wakeup_reason;
ds_wakeup_reason = esp_sleep_get_wakeup_cause(); // << causes Core 0 panic'ed (Illegal instruction)
if(ds_wakeup_reason == 7) // GPIO Caused Wakeup
{
if(Armed == 1) // button has been released
{
Armed = 0;
esp_deep_sleep_enable_gpio_wakeup(1ULL << BUTTON1,ESP_GPIO_WAKEUP_GPIO_LOW); // << causes Core 0 panic'ed (Illegal instruction)
++Water;
}
if(Armed == 0) // button has been pushed
{
Armed = 1;
esp_deep_sleep_enable_gpio_wakeup(1ULL << BUTTON1,ESP_GPIO_WAKEUP_GPIO_HIGH); // << causes Core 0 panic'ed (Illegal instruction)
}
}
//Now go back to deep sleep
CLEAR_PERI_REG_MASK(RTC_CNTL_STATE0_REG,RTC_CNTL_SLEEP_EN);
SET_PERI_REG_MASK(RTC_CNTL_STATE0_REG,RTC_CNTL_SLEEP_EN);
while(true) {
;
}
// for any other reason, then continue to wake up normally
}
Could anyone suggest how I implement these 3 lines in ROM style code.
Many Thanks