From 4eaf664653e7f2f4397f24d881ec4bf2032473ce Mon Sep 17 00:00:00 2001 From: Uri Shaked Date: Fri, 29 Oct 2021 13:04:38 +0300 Subject: fix(timer): setting TCNT doesn't update OCRA #111 --- src/peripherals/timer.ts | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/peripherals/timer.ts') diff --git a/src/peripherals/timer.ts b/src/peripherals/timer.ts index b597d07..53777e2 100644 --- a/src/peripherals/timer.ts +++ b/src/peripherals/timer.ts @@ -576,6 +576,14 @@ export class AVRTimer { if (this.tcntUpdated) { this.tcnt = this.tcntNext; this.tcntUpdated = false; + if ( + (this.tcnt === 0 && this.ocrUpdateMode === OCRUpdateMode.Bottom) || + (this.tcnt === this.TOP && this.ocrUpdateMode === OCRUpdateMode.Top) + ) { + this.ocrA = this.nextOcrA; + this.ocrB = this.nextOcrB; + this.ocrC = this.nextOcrC; + } } if (this.updateDivider) { const { CS } = this; -- cgit v1.2.3