diff --git a/components/hal/esp32/include/hal/timer_ll.h b/components/hal/esp32/include/hal/timer_ll.h index 2ec4286f77..447f3fded9 100644 --- a/components/hal/esp32/include/hal/timer_ll.h +++ b/components/hal/esp32/include/hal/timer_ll.h @@ -103,6 +103,7 @@ static inline void timer_ll_set_counter_value(timg_dev_t *hw, timer_idx_t timer_ FORCE_INLINE_ATTR void timer_ll_get_counter_value(timg_dev_t *hw, timer_idx_t timer_num, uint64_t *timer_val) { hw->hw_timer[timer_num].update = 1; + while (hw->hw_timer[timer_num].update) {} *timer_val = ((uint64_t) hw->hw_timer[timer_num].cnt_high << 32) | (hw->hw_timer[timer_num].cnt_low); } diff --git a/components/hal/esp32s2/include/hal/timer_ll.h b/components/hal/esp32s2/include/hal/timer_ll.h index 6a9a235f8a..3e8bc1930f 100644 --- a/components/hal/esp32s2/include/hal/timer_ll.h +++ b/components/hal/esp32s2/include/hal/timer_ll.h @@ -99,6 +99,7 @@ static inline void timer_ll_set_counter_value(timg_dev_t *hw, timer_idx_t timer_ FORCE_INLINE_ATTR void timer_ll_get_counter_value(timg_dev_t *hw, timer_idx_t timer_num, uint64_t *timer_val) { hw->hw_timer[timer_num].update.update = 1; + while (hw->hw_timer[timer_num].update.update) {} *timer_val = ((uint64_t) hw->hw_timer[timer_num].cnt_high << 32) | (hw->hw_timer[timer_num].cnt_low); } diff --git a/components/hal/esp32s3/include/hal/timer_ll.h b/components/hal/esp32s3/include/hal/timer_ll.h index ced9251201..994cb48faf 100644 --- a/components/hal/esp32s3/include/hal/timer_ll.h +++ b/components/hal/esp32s3/include/hal/timer_ll.h @@ -100,6 +100,7 @@ static inline void timer_ll_set_counter_value(timg_dev_t *hw, timer_idx_t timer_ FORCE_INLINE_ATTR void timer_ll_get_counter_value(timg_dev_t *hw, timer_idx_t timer_num, uint64_t *timer_val) { hw->hw_timer[timer_num].update.update = 1; + while (hw->hw_timer[timer_num].update.update) {} *timer_val = ((uint64_t) hw->hw_timer[timer_num].cnt_high.hi << 32) | (hw->hw_timer[timer_num].cnt_low); }