aboutsummaryrefslogtreecommitdiff
path: root/src/peripherals/timer.ts
diff options
context:
space:
mode:
authorUri Shaked2021-10-29 13:04:38 +0300
committerUri Shaked2021-10-29 13:04:38 +0300
commit4eaf664653e7f2f4397f24d881ec4bf2032473ce (patch)
tree864dece0fdae6e37f8f8c38af27bd02b2749469f /src/peripherals/timer.ts
parent0.18.4 (diff)
downloadavr8js-4eaf664653e7f2f4397f24d881ec4bf2032473ce.tar.gz
avr8js-4eaf664653e7f2f4397f24d881ec4bf2032473ce.tar.bz2
avr8js-4eaf664653e7f2f4397f24d881ec4bf2032473ce.zip
fix(timer): setting TCNT doesn't update OCRA #111
Diffstat (limited to 'src/peripherals/timer.ts')
-rw-r--r--src/peripherals/timer.ts8
1 files changed, 8 insertions, 0 deletions
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;