8000 Finish overshoot math fixes. · dok-net/arduino-esp8266@ab8fc07 · GitHub
[go: up one dir, main page]

Skip to content

Commit ab8fc07

Browse files
committed
Finish overshoot math fixes.
1 parent d264d58 commit ab8fc07

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

cores/esp8266/core_esp8266_waveform.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,9 @@ static ICACHE_RAM_ATTR void timer1Interrupt() {
318318
}
319319
uint32_t nextEdgeCcy;
320320
if (waveform.states & (1UL << pin)) {
321-
// up to and including this period 100% duty
321+
// up to and including this period 100% duty
322322
const bool endOfPeriod = wave.nextPeriodCcy == wave.endDutyCcy;
323-
// active configuration and forward 100% duty
323+
// active configuration and forward 100% duty
324324
if (!idleCcys) {
325325
wave.nextPeriodCcy += (fwdPeriods + 1) * wave.periodCcys;
326326
wave.endDutyCcy = wave.nextPeriodCcy;
@@ -333,15 +333,9 @@ static ICACHE_RAM_ATTR void timer1Interrupt() {
333333
wave.nextPeriodCcy += wave.periodCcys;
334334
nextEdgeCcy = wave.endDutyCcy;
335335
}
336-
else if (fwdPeriods) {
337-
// maintain phase, maintain duty/idle ratio, temporarily reduce frequency by skipPeriods
338-
fwdPeriods = (overshootCcys + wave.periodCcys) / wave.dutyCcys;
339-
wave.endDutyCcy += fwdPeriods * wave.dutyCcys;
340-
wave.nextPeriodCcy += fwdPeriods * wave.periodCcys;
341-
nextEdgeCcy = wave.endDutyCcy;
342-
}
343336
else {
344337
waveform.states ^= 1UL << pin;
338+
// the idle cycle code updating for the next period will approximate the duty/idle ratio.
345339
nextEdgeCcy = wave.nextPeriodCcy + overshootCcys;
346340
if (pin == 16) {
347341
GP16O &= ~1; // GPIO16 write slow as it's RMW
@@ -360,7 +354,7 @@ static ICACHE_RAM_ATTR void timer1Interrupt() {
360354
waveform.states ^= 1UL << pin;
361355
if (fwdPeriods)
362356
{
363-
// maintain phase, maintain duty/idle ratio, temporarily reduce frequency by skipPeriods
357+
// maintain phase, maintain duty/idle ratio, temporarily reduce frequency by fwdPeriods
364358
wave.endDutyCcy =
365359
wave.nextPeriodCcy + (fwdPeriods + 1) * wave.dutyCcys +
366360
(overshootCcys + wave.dutyCcys - fwdPeriods * wave.periodCcys);

0 commit comments

Comments
 (0)
0