aboutsummaryrefslogtreecommitdiff
path: root/src/timer.spec.ts
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/timer.spec.ts15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/timer.spec.ts b/src/timer.spec.ts
index dd45cee..4d631a7 100644
--- a/src/timer.spec.ts
+++ b/src/timer.spec.ts
@@ -1,5 +1,5 @@
import { CPU } from './cpu';
-import { AVRTimer, timer0Config } from './timer';
+import { AVRTimer, timer0Config, timer2Config } from './timer';
describe('timer', () => {
let cpu: CPU;
@@ -188,4 +188,17 @@ describe('timer', () => {
expect(cpu.pc).toEqual(0x1e);
expect(cpu.cycles).toEqual(3);
});
+
+ it('timer2 should count every 256 ticks when prescaler is 6 (issue #5)', () => {
+ const timer = new AVRTimer(cpu, timer2Config);
+ cpu.data[0xb1] = 0x6; // TCCR1B.CS <- 6
+
+ cpu.cycles = 511;
+ timer.tick();
+ expect(cpu.data[0xb2]).toEqual(1); // TCNT2 should be 2
+
+ cpu.cycles = 512;
+ timer.tick();
+ expect(cpu.data[0xb2]).toEqual(2); // TCNT2 should be 2
+ });
});