From 6e12910f8eca0798f02ede2fbde23e4eb99ec0d3 Mon Sep 17 00:00:00 2001 From: Marius Vikhammer Date: Thu, 18 Jun 2026 11:46:23 +0800 Subject: [PATCH] fix(ulp): use SoC RC_FAST frequency for LP core delay Use the target RC_FAST approximation for LP core delay conversion. This prevents ESP32-S31 from under-delaying when running from RC_FAST. Co-authored-by: Cursor --- .../lp_core/shared/include/ulp_lp_core_cpu_freq_shared.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/components/ulp/lp_core/shared/include/ulp_lp_core_cpu_freq_shared.h b/components/ulp/lp_core/shared/include/ulp_lp_core_cpu_freq_shared.h index 3c0970a6a77..b690a9186a1 100644 --- a/components/ulp/lp_core/shared/include/ulp_lp_core_cpu_freq_shared.h +++ b/components/ulp/lp_core/shared/include/ulp_lp_core_cpu_freq_shared.h @@ -6,13 +6,14 @@ #pragma once #include "sdkconfig.h" +#include "soc/clk_tree_defs.h" #include "soc/soc_caps.h" /* LP_FAST_CLK is not very accurate, for now use a rough estimate */ #if CONFIG_RTC_FAST_CLK_SRC_RC_FAST -#define LP_CORE_CPU_FREQUENCY_HZ 16000000U /* For P4 TRM says 20 MHz by default, but we tune it closer to 16 MHz */ -#define LP_CORE_CYCLES_PER_US_NUM 16U -#define LP_CORE_CYCLES_PER_US_DENOM 1U +#define LP_CORE_CPU_FREQUENCY_HZ SOC_CLK_RC_FAST_FREQ_APPROX +#define LP_CORE_CYCLES_PER_US_NUM (SOC_CLK_RC_FAST_FREQ_APPROX / 500000U) +#define LP_CORE_CYCLES_PER_US_DENOM 2U #elif CONFIG_RTC_FAST_CLK_SRC_XTAL #if SOC_XTAL_SUPPORT_48M #define LP_CORE_CPU_FREQUENCY_HZ 48000000U