Skip to content

Commit f861b7d

Browse files
committed
fix(esp_hw_support): config lact in critical
1 parent d445536 commit f861b7d

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

components/esp_pm/pm_impl.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,10 @@ static void IRAM_ATTR do_switch(pm_mode_t new_mode)
667667
#if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
668668
esp_clk_utils_mspi_speed_mode_sync_before_cpu_freq_switching(new_config.source_freq_mhz, new_config.freq_mhz);
669669
#endif
670+
extern portMUX_TYPE s_time_update_lock;
671+
portENTER_CRITICAL_SAFE(&s_time_update_lock);
670672
rtc_clk_cpu_freq_set_config_fast(&new_config);
673+
portEXIT_CRITICAL_SAFE(&s_time_update_lock);
671674
#if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
672675
esp_clk_utils_mspi_speed_mode_sync_after_cpu_freq_switching(new_config.source_freq_mhz, new_config.freq_mhz);
673676
#endif

components/esp_timer/src/esp_timer_impl_lac.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,9 @@ esp_err_t esp_timer_impl_init(intr_handler_t alarm_handler)
276276
* will not cause issues in practice.
277277
*/
278278
REG_SET_BIT(INT_ENA_REG, TIMG_LACT_INT_ENA);
279+
portENTER_CRITICAL_SAFE(&s_time_update_lock);
279280
timer_ll_set_lact_clock_prescale(TIMER_LL_GET_HW(LACT_MODULE), esp_clk_apb_freq() / MHZ / LACT_TICKS_PER_US);
281+
portEXIT_CRITICAL_SAFE(&s_time_update_lock);
280282
// Set the step for the sleep mode when the timer will work
281283
// from a slow_clk frequency instead of the APB frequency.
282284
uint32_t slowclk_ticks_per_us = esp_clk_slowclk_cal_get() * LACT_TICKS_PER_US;

0 commit comments

Comments
 (0)