+10
-5
lines changedFilter options
+10
-5
lines changed Original file line number Diff line number Diff line change
@@ -72,10 +72,13 @@
72
72
*/
73
73
#define CCOMPARE_UPDATE_TIMEOUT 1000000
74
74
75
-
/* When changing CCOMPARE, don't allow changes if the difference is less
76
-
* than this. This is to prevent setting CCOMPARE below CCOUNT.
75
+
/* The number of CPU cycles required from obtaining the base ccount to configuring
76
+
the calculated ccompare value. (In order to avoid ccompare being updated to a value
77
+
smaller than the current ccount, this update should be discarded if the next tick
78
+
is too close to this moment, and this value is used to calculate the threshold for
79
+
determining whether or not a skip is required.)
77
80
*/
78
-
#define CCOMPARE_MIN_CYCLES_IN_FUTURE 1000
81
+
#define CCOMPARE_PREPARE_CYCLES_IN_FREQ_UPDATE 60
79
82
#endif // CONFIG_FREERTOS_SYSTICK_USES_CCOUNT
80
83
81
84
/* When light sleep is used, wake this number of microseconds earlier than
@@ -542,15 +545,17 @@ static void IRAM_ATTR do_switch(pm_mode_t new_mode)
542
545
* would happen without the frequency change.
543
546
* Assumes that the new_frequency = old_frequency * s_ccount_mul / s_ccount_div.
544
547
*/
545
-
static void IRAM_ATTR update_ccompare(void)
548
+
static __attribute__((optimize("-O2"))) void IRAM_ATTR update_ccompare(void)
546
549
{
550
+
uint32_t ccompare_min_cycles_in_future = ((s_ccount_div + s_ccount_mul - 1) / s_ccount_mul) * CCOMPARE_PREPARE_CYCLES_IN_FREQ_UPDATE;
547
551
#if CONFIG_PM_UPDATE_CCOMPARE_HLI_WORKAROUND
548
552
/* disable level 4 and below */
549
553
uint32_t irq_status = XTOS_SET_INTLEVEL(XCHAL_DEBUGLEVEL - 2);
550
554
#endif
551
555
uint32_t ccount = esp_cpu_get_cycle_count();
552
556
uint32_t ccompare = XTHAL_GET_CCOMPARE(XT_TIMER_INDEX);
553
-
if ((ccompare - CCOMPARE_MIN_CYCLES_IN_FUTURE) - ccount < UINT32_MAX / 2) {
557
+
558
+
if ((ccompare - ccompare_min_cycles_in_future) - ccount < UINT32_MAX / 2) {
554
559
uint32_t diff = ccompare - ccount;
555
560
uint32_t diff_scaled = (diff * s_ccount_mul + s_ccount_div - 1) / s_ccount_div;
556
561
if (diff_scaled < _xt_tick_divisor) {
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4