Skip to content

Commit 0d8e5b4

Browse files
committed
pwm test
1 parent 554f23e commit 0d8e5b4

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

src/peripherals/pwm.spec.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
2+
import { createTestDriver } from '../../test-utils/create-test-driver';
3+
import { ICortexTestDriver } from '../../test-utils/test-driver';
4+
import { RP2040TestDriver } from '../../test-utils/test-driver-rp2040';
5+
6+
describe('PWM', () => {
7+
let cpu: ICortexTestDriver;
8+
9+
beforeEach(async () => {
10+
cpu = await createTestDriver();
11+
});
12+
13+
afterEach(async () => {
14+
await cpu.tearDown();
15+
});
16+
17+
it('should not hang', async () => {
18+
await cpu.writeUint32(0x4005008c,0);
19+
await cpu.writeUint32(0x40050094,0);
20+
await cpu.writeUint32(0x40050098,0);
21+
await cpu.writeUint32(0x4005009c,9);
22+
await cpu.writeUint32(0x40050090,16);
23+
for(let i=0; i < 1000; i++) { cpu.singleStep(); console.log(i); }
24+
});
25+
});

test-utils/test-driver-rp2040.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ export class RP2040TestDriver implements ICortexTestDriver {
117117
}
118118

119119
async singleStep() {
120-
this.rp2040.step();
120+
const cycles = this.rp2040.core.executeInstruction();
121+
this.rp2040.clock.tick(cycles * 1e9 / 125_000_000); // 125 MHz
121122
}
122123

123124
async readRegisters(): Promise<ICortexRegisters> {

0 commit comments

Comments
 (0)