diff options
| author | Uri Shaked | 2020-12-26 00:24:54 +0200 |
|---|---|---|
| committer | Uri Shaked | 2020-12-26 00:24:54 +0200 |
| commit | 02e5b211c6e31ca8f9ec19ff6ec52d4f5bbef568 (patch) | |
| tree | 67a624b2baf932d2dfe7ef709ac32ead8e423ff8 /src/peripherals/timer.ts | |
| parent | 0.14.6 (diff) | |
| download | avr8js-02e5b211c6e31ca8f9ec19ff6ec52d4f5bbef568.tar.gz avr8js-02e5b211c6e31ca8f9ec19ff6ec52d4f5bbef568.tar.bz2 avr8js-02e5b211c6e31ca8f9ec19ff6ec52d4f5bbef568.zip | |
fix(timer): Overflow interrupt fires twice #80
fix #80
Diffstat (limited to '')
| -rw-r--r-- | src/peripherals/timer.ts | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/peripherals/timer.ts b/src/peripherals/timer.ts index 957aa78..6ea29e3 100644 --- a/src/peripherals/timer.ts +++ b/src/peripherals/timer.ts @@ -445,7 +445,7 @@ export class AVRTimer { // OCRUpdateMode.Bottom only occurs in Phase Correct modes, handled by phasePwmCount(). // Thus we only handle TOVUpdateMode.Top or TOVUpdateMode.Max here. if ( - (newVal === TOP || overflow) && + (newVal === TOP || (overflow && val < TOP)) && (this.tovUpdateMode == TOVUpdateMode.Top || TOP === this.MAX) ) { cpu.setInterruptFlag(this.OVF); @@ -453,7 +453,11 @@ export class AVRTimer { } } if (this.tcntUpdated) { + const { TOP } = this; this.tcnt = this.tcntNext; + if (this.tcnt === TOP && (this.tovUpdateMode == TOVUpdateMode.Top || TOP === this.MAX)) { + cpu.setInterruptFlag(this.OVF); + } this.tcntUpdated = false; } if (this.updateDivider) { |
