From 3f6515232eddb570605e1b8fc0bcb125f1a610a3 Mon Sep 17 00:00:00 2001 From: Cao Sen Miao Date: Tue, 28 Nov 2023 17:08:57 +0800 Subject: [PATCH] brownout: Disable the hardware BOD when BOD interrupt is enabled --- components/esp_system/README.md | 8 +++++++- components/hal/esp32c3/brownout_hal.c | 3 +++ components/hal/esp32s3/brownout_hal.c | 3 +++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/components/esp_system/README.md b/components/esp_system/README.md index b54343b21b..f01e59d828 100644 --- a/components/esp_system/README.md +++ b/components/esp_system/README.md @@ -26,4 +26,10 @@ If persistence is enabled, RTC time is also used in conjuction with system time. 4. RTC time (`esp_rtc_get_time_us`) -Time read from RTC timer. \ No newline at end of file +Time read from RTC timer. + +### Brownout + +on some boards, we name BOD1 as ana_bod, to unify the usage, using BOD1 in following passage. + +BOD1 will be a little faster then BOD0, but BOD0 can be widely used(can reset rf, flash, or using interrupt, etc.) So, in IDF code, we use BOD1 in bootloader and BOD0 in the app. diff --git a/components/hal/esp32c3/brownout_hal.c b/components/hal/esp32c3/brownout_hal.c index 5dac36f067..36dd3d5d28 100644 --- a/components/hal/esp32c3/brownout_hal.c +++ b/components/hal/esp32c3/brownout_hal.c @@ -32,6 +32,9 @@ void brownout_hal_config(const brownout_hal_config_t *cfg) .rst_sel = 1, }; RTCCNTL.brown_out = brown_out_reg; + // If brownout software control is enabled, hw ana reset should be disabled, because it always has the highest priority. + RTCCNTL.brown_out.ana_rst_en = false; + } void brownout_hal_intr_enable(bool enable) diff --git a/components/hal/esp32s3/brownout_hal.c b/components/hal/esp32s3/brownout_hal.c index 99bd5e52bf..e41f5e32c6 100644 --- a/components/hal/esp32s3/brownout_hal.c +++ b/components/hal/esp32s3/brownout_hal.c @@ -33,6 +33,9 @@ void brownout_hal_config(const brownout_hal_config_t *cfg) .rst_sel = 1, }; RTCCNTL.brown_out = brown_out_reg; + // If brownout software control is enabled, hw ana reset should be disabled, because it always has the highest priority. + RTCCNTL.brown_out.ana_rst_en = false; + } void brownout_hal_intr_enable(bool enable)