@@ -52,10 +52,10 @@ constexpr uint32_t ISRTIMEOUTCCYS = microsecondsToClockCycles(18);
52
52
// decrement the next IRQ's timer value by a bit so we can actually catch the
53
53
// real CPU cycle count we want for the waveforms.
54
54
constexpr int32_t DELTAIRQCCYS = clockCyclesPerMicrosecond() == 160 ?
55
- microsecondsToClockCycles (2 ) >> 1 : microsecondsToClockCycles(2 );
55
+ microsecondsToClockCycles (1 ) >> 1 : microsecondsToClockCycles(1 );
56
56
// The latency between in-ISR rearming of the timer and the earliest firing
57
57
constexpr int32_t IRQLATENCYCCYS = clockCyclesPerMicrosecond() == 160 ?
58
- ( microsecondsToClockCycles(3 ) / 2 ) >> 1 : ( microsecondsToClockCycles(3 ) / 2 );
58
+ microsecondsToClockCycles (1 ) >> 1 : microsecondsToClockCycles(1 );
59
59
60
60
// for INFINITE, the NMI proceeds on the waveform without expiry deadline.
61
61
// for EXPIRES, the NMI expires the waveform automatically on the expiry ccy.
@@ -108,7 +108,7 @@ static void initTimer() {
108
108
ETS_FRC_TIMER1_NMI_INTR_ATTACH (timer1Interrupt);
109
109
timer1_enable (TIM_DIV1, TIM_EDGE, TIM_SINGLE);
110
110
waveform.timer1Running = true ;
111
- timer1_write (CPU2X & 1 ? microsecondsToClockCycles ( 1 ) >> 1 : microsecondsToClockCycles ( 1 ) ); // Cause an interrupt post-haste
111
+ timer1_write (IRQLATENCYCCYS ); // Cause an interrupt post-haste
112
112
}
113
113
114
114
static void ICACHE_RAM_ATTR deinitTimer () {
@@ -189,7 +189,7 @@ int startWaveformClockCycles(uint8_t pin, uint32_t highCcys, uint32_t lowCcys,
189
189
}
190
190
else if (T1V > ((clockCyclesPerMicrosecond () == 160 ) ? (IRQLATENCYCCYS + DELTAIRQCCYS) >> 1 : IRQLATENCYCCYS + DELTAIRQCCYS)) {
191
191
// Must not interfere if Timer is due shortly
192
- timer1_write (( clockCyclesPerMicrosecond () == 160 ) ? microsecondsToClockCycles ( 1 ) >> 1 : microsecondsToClockCycles ( 1 ) );
192
+ timer1_write (IRQLATENCYCCYS );
193
193
}
194
194
}
195
195
else {
@@ -225,7 +225,7 @@ int ICACHE_RAM_ATTR stopWaveform(uint8_t pin) {
225
225
std::atomic_thread_fence (std::memory_order_release);
226
226
// Must not interfere if Timer is due shortly
227
227
if (T1V > ((clockCyclesPerMicrosecond () == 160 ) ? (IRQLATENCYCCYS + DELTAIRQCCYS) >> 1 : IRQLATENCYCCYS + DELTAIRQCCYS)) {
228
- timer1_write (( clockCyclesPerMicrosecond () == 160 ) ? microsecondsToClockCycles ( 1 ) >> 1 : microsecondsToClockCycles ( 1 ) );
228
+ timer1_write (IRQLATENCYCCYS );
229
229
}
230
230
while (waveform.toDisableBits ) {
231
231
/* no-op */ // Can't delay() since stopWaveform may be called from an IRQ
0 commit comments