Skip to content

Commit 5cabb91

Browse files
committed
Event timestamps are all recorded for compile-time CPU frequency, the timer ticks conversion
must be set at compile-time also. The SDK WiFi 160MHz boost mitigation temporarily handles the CPU clock running twice as fast.
1 parent c362ba0 commit 5cabb91

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

cores/esp8266/core_esp8266_waveform.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,9 @@ static ICACHE_RAM_ATTR void timer1Interrupt() {
452452
}
453453

454454
// Register access is fast and edge IRQ was configured before.
455-
// Timer is 80MHz fixed. 160MHz binaries need scaling,
456-
// 80MHz binaries in 160MHz boost (SDK) need NMI scaling
457-
// to maintain duty/idle ratio.
458-
T1L = CPU2X & 1 ? nextTimerCcys >> 1 : nextTimerCcys;
455+
// Timer is 80MHz fixed. 160MHz binaries need scaling.
456+
// For dynamic CPU clock frequency switch in loop the scaling logic would have to be adapted.
457+
// Using constexpr makes sure that the CPU clock frequency is compile-time fixed.
458+
constexpr bool cpuFreq80MHz = clockCyclesPerMicrosecond() == 80;
459+
T1L = cpuFreq80MHz ? nextTimerCcys : nextTimerCcys >> 1;
459460
}

0 commit comments

Comments
 (0)