Skip to content

Commit bbe755f

Browse files
soypatdeadprogram
authored andcommitted
fix bug in rp2040 SetPeriod implementation
1 parent 635d322 commit bbe755f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/machine/machine_rp2040_pwm.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,9 @@ func (pwm *pwmGroup) setPeriod(period uint64) error {
260260
maxTop = math.MaxUint16
261261
// start algorithm at 95% Top. This allows us to undershoot period with prescale.
262262
topStart = 95 * maxTop / 100
263-
milliseconds = 1_000_000_000
263+
nanosecond = 1 // 1e-9 [s]
264+
microsecond = 1000 * nanosecond // 1e-6 [s]
265+
milliseconds = 1000 * microsecond // 1e-3 [s]
264266
// Maximum Period is 268369920ns on rp2040, given by (16*255+15)*8*(1+0xffff)*(1+1)/16
265267
// With no phase shift max period is half of this value.
266268
maxPeriod = 268 * milliseconds

0 commit comments

Comments
 (0)