aboutsummaryrefslogtreecommitdiff
path: root/demo/src
diff options
context:
space:
mode:
authorUri Shaked2020-04-16 18:42:12 +0300
committerGitHub2020-04-16 18:42:12 +0300
commit9f06d4e171ef70c464b0ccc0262d8c9bba67d11e (patch)
tree3b07fed997009f9ac88ffaf27e2ffe802b493c6d /demo/src
parentchore(deps): jest 25.3.0, ts-jest 25.3.1 (diff)
parenttest(timer): add more 16-bit timer tests (diff)
downloadavr8js-9f06d4e171ef70c464b0ccc0262d8c9bba67d11e.tar.gz
avr8js-9f06d4e171ef70c464b0ccc0262d8c9bba67d11e.tar.bz2
avr8js-9f06d4e171ef70c464b0ccc0262d8c9bba67d11e.zip
Merge pull request #30 from wokwi/16bit-timer-fix
Implement 16-bit timers
Diffstat (limited to '')
-rw-r--r--demo/src/execute.ts10
1 files changed, 7 insertions, 3 deletions
diff --git a/demo/src/execute.ts b/demo/src/execute.ts
index ee5278e..2ba9ee0 100644
--- a/demo/src/execute.ts
+++ b/demo/src/execute.ts
@@ -3,6 +3,7 @@ import {
AVRTimer,
CPU,
timer0Config,
+ timer1Config,
AVRIOPort,
AVRUSART,
portBConfig,
@@ -19,7 +20,8 @@ const FLASH = 0x8000;
export class AVRRunner {
readonly program = new Uint16Array(FLASH);
readonly cpu: CPU;
- readonly timer: AVRTimer;
+ readonly timer0: AVRTimer;
+ readonly timer1: AVRTimer;
readonly portB: AVRIOPort;
readonly portC: AVRIOPort;
readonly portD: AVRIOPort;
@@ -31,7 +33,8 @@ export class AVRRunner {
constructor(hex: string) {
loadHex(hex, new Uint8Array(this.program.buffer));
this.cpu = new CPU(this.program);
- this.timer = new AVRTimer(this.cpu, timer0Config);
+ this.timer0 = new AVRTimer(this.cpu, timer0Config);
+ this.timer1 = new AVRTimer(this.cpu, timer1Config);
this.portB = new AVRIOPort(this.cpu, portBConfig);
this.portC = new AVRIOPort(this.cpu, portCConfig);
this.portD = new AVRIOPort(this.cpu, portDConfig);
@@ -44,7 +47,8 @@ export class AVRRunner {
const cyclesToRun = this.cpu.cycles + this.workUnitCycles;
while (this.cpu.cycles < cyclesToRun) {
avrInstruction(this.cpu);
- this.timer.tick();
+ this.timer0.tick();
+ this.timer1.tick();
this.usart.tick();
}