]> granicus.if.org Git - esp-idf/commitdiff
unit tests: fix ref_clock value obtained due to overflow
authorIvan Grokhotkov <ivan@espressif.com>
Thu, 7 Sep 2017 17:33:20 +0000 (01:33 +0800)
committerIvan Grokhotkov <ivan@espressif.com>
Wed, 18 Oct 2017 06:19:15 +0000 (14:19 +0800)
tools/unit-test-app/components/unity/ref_clock.c

index 696bd0a4d3699385030f1fe213b675473afadfc5..94afe01bd79445302ad9a9a583f93bac3599614e 100644 (file)
@@ -159,6 +159,8 @@ uint64_t ref_clock_get()
     uint32_t microseconds = PCNT.cnt_unit[REF_CLOCK_PCNT_UNIT].cnt_val;
     uint32_t milliseconds = s_milliseconds;
     if (PCNT.int_st.val & BIT(REF_CLOCK_PCNT_UNIT)) {
+        // refresh counter value, in case the overflow has happened after reading cnt_val
+        microseconds = PCNT.cnt_unit[REF_CLOCK_PCNT_UNIT].cnt_val;
         milliseconds += REF_CLOCK_PRESCALER_MS;
     }
     portEXIT_CRITICAL(&s_lock);