From a774df984fe156a037b338000cc03f723f968224 Mon Sep 17 00:00:00 2001 From: Uri Shaked Date: Sat, 19 Jun 2021 23:47:35 +0300 Subject: fix(timer): Timer1 PWM issues #94 close #94 --- src/peripherals/timer.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/peripherals/timer.ts') diff --git a/src/peripherals/timer.ts b/src/peripherals/timer.ts index e620459..c79cc7c 100644 --- a/src/peripherals/timer.ts +++ b/src/peripherals/timer.ts @@ -548,13 +548,13 @@ export class AVRTimer { private timerUpdated(value: number, prevValue: number) { const { ocrA, ocrB } = this; const overflow = prevValue > value; - if ((prevValue < ocrA || overflow) && value >= ocrA) { + if (((prevValue < ocrA || overflow) && value >= ocrA) || (prevValue < ocrA && overflow)) { this.cpu.setInterruptFlag(this.OCFA); if (this.compA) { this.updateCompPin(this.compA, 'A'); } } - if ((prevValue < ocrB || overflow) && value >= ocrB) { + if (((prevValue < ocrB || overflow) && value >= ocrB) || (prevValue < ocrB && overflow)) { this.cpu.setInterruptFlag(this.OCFB); if (this.compB) { this.updateCompPin(this.compB, 'B'); -- cgit v1.2.3