From 688eba38b5998bc9b6edab80418dc344f3431200 Mon Sep 17 00:00:00 2001 From: Uri Shaked Date: Wed, 7 Jul 2021 19:51:10 +0300 Subject: [PATCH] fix(timer): only set ICR hook for 16-bit timers The ICR (Input Capture Register) only exists for 16-bit timers. --- src/peripherals/timer.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/peripherals/timer.ts b/src/peripherals/timer.ts index c79cc7c..cd55f12 100644 --- a/src/peripherals/timer.ts +++ b/src/peripherals/timer.ts @@ -320,10 +320,10 @@ export class AVRTimer { this.ocrB = this.nextOcrB; } }; - this.cpu.writeHooks[config.ICR] = (value: u8) => { - this.icr = (this.highByteTemp << 8) | value; - }; if (this.config.bits === 16) { + this.cpu.writeHooks[config.ICR] = (value: u8) => { + this.icr = (this.highByteTemp << 8) | value; + }; const updateTempRegister = (value: u8) => { this.highByteTemp = value; };