8000 AutoPwm correction moved to correct location - after overshoot recalc… · dok-net/arduino-esp8266@d264d58 · GitHub
[go: up one dir, main page]

Skip to content

Commit d264d58

Browse files
committed
AutoPwm correction moved to correct location - after overshoot recalc - and allow limited duty floating
1 parent 94eea6b commit d264d58

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
@@ -301,10 +301,6 @@ static ICACHE_RAM_ATTR void timer1Interrupt() {
301301

302302
int32_t overshootCcys = now - wave.nextEventCcy;
303303
if (overshootCcys >= 0) {
304-
if (!wave.autoPwm) {
305-
// for best effort hard timings
306-
overshootCcys = 0;
307-
}
308304
if (WaveformMode::EXPIRES == wave.mode && wave.nextEventCcy == wave.expiryCcy) {
309305
// Disable any waveforms that are done
310306
waveform.enabled ^= 1UL << pin;
@@ -315,6 +311,11 @@ static ICACHE_RAM_ATTR void timer1Interrupt() {
315311
const uint32_t idleCcys = wave.periodCcys - wave.dutyCcys;
316312
uint32_t fwdPeriods = static_cast<uint32_t>(overshootCcys) >= idleCcys ?
317313
((overshootCcys + wave.dutyCcys) / wave.periodCcys) : 0;
314+
if (fwdPeriods && !wave.autoPwm) {
315+
// for best effort hard timings - allow only limited duty cycle floating
316+
fwdPeriods = 0;
317+
overshootCcys = 0;
318+
}
318319
uint32_t nextEdgeCcy;
319320
if (waveform.states & (1UL << pin)) {
320321
// up to and including this period 100% duty

0 commit comments

Comments
 (0)
0