Skip to content

Commit 8286545

Browse files
committed
Prevent initial bad clock drift calculation on timer init.
1 parent f4f58e9 commit 8286545

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

cores/esp8266/core_esp8266_waveform_phase.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ static void initTimer() {
122122
ETS_FRC_TIMER1_NMI_INTR_ATTACH(timer1Interrupt);
123123
timer1_enable(TIM_DIV1, TIM_EDGE, TIM_SINGLE);
124124
waveform.timer1Running = true;
125+
waveform.nextEventCcy = ESP.getCycleCount() + IRQLATENCYCCYS;
125126
timer1_write(IRQLATENCYCCYS); // Cause an interrupt post-haste
126127
}
127128

@@ -229,6 +230,7 @@ IRAM_ATTR int stopWaveform_weak(uint8_t pin) {
229230
std::atomic_thread_fence(std::memory_order_release);
230231
// Must not interfere if Timer is due shortly
231232
if (T1V > IRQLATENCYCCYS) {
233+
waveform.nextEventCcy = ESP.getCycleCount() + IRQLATENCYCCYS;
232234
timer1_write(IRQLATENCYCCYS);
233235
}
234236
while (waveform.toDisableBits) {

0 commit comments

Comments
 (0)