Skip to content

Commit 4c23987

Browse files
committed
Fix freq and period
1 parent afcb022 commit 4c23987

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/helpers/simulator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const offsetCounter = (
2020
) => cpuToTcnt(tcntToCpu(counter, top) + offset, top, isDoubleSlope)
2121

2222
const getTimerLength = (top: number, isDoubleSlope: boolean) => {
23-
return isDoubleSlope ? top * 2 : top
23+
return isDoubleSlope ? top * 2 : top + 1
2424
}
2525
const cpuToTcnt = (cpu: number, top: number, isDoubleSlope: boolean) => {
2626
while (cpu < 0 && top > 0) cpu += top
@@ -78,7 +78,7 @@ export default function simTimer({
7878
}: Props) {
7979
const isDoubleSlope = ['PCPWM', 'PFCPWM'].includes(timerMode)
8080
const timerLength = getTimerLength(top, isDoubleSlope)
81-
const prescaledCPUEnd = timerLength * 4 + 2
81+
const prescaledCPUEnd = timerLength * 4
8282
const results = {
8383
t: [] as number[],
8484
cpu: [] as number[],

0 commit comments

Comments
 (0)