0

I am using the 8KB of static RAM on the RTC inside the ESP32 to save a small amount of sensor data to reduce power consumption by transmitting less frequently. But I am having no luck with even the simple example code:

RTC_DATA_ATTR uint32_t testValue = 0;

{
    ESP_LOGE(TAG, "testValue = %d", testValue++);
    ...
}

In the monitor, I can see the value as 0 first time round, but then it's anyone's guess.

E (109) app_main: testValue = 0
...
...
E (109) app_main: testValue = -175962388

EDIT

Also tried the attribute:

RTC_NOINIT_ATTR uint32_t testValue = 0;

What am I doing wrong?

monkey
  • 1,213
  • 2
  • 13
  • 35

1 Answers1

4

I received an answer from other channels that I'd like to share on. The solution was to set:

esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_SLOW_MEM, ESP_PD_OPTION_ON);
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_FAST_MEM, ESP_PD_OPTION_ON);

So the RTC memory regions are enabled. In my case, I had specifically disabled them in another area of the code (the deep sleep power management code). This solution doesn't significantly affect the deep sleep power consumption ~ 10 uA.

Dharman
  • 30,962
  • 25
  • 85
  • 135
monkey
  • 1,213
  • 2
  • 13
  • 35