diff options
author | soypat <[email protected]> | 2023-06-02 20:42:47 -0300 |
---|---|---|
committer | Ron Evans <[email protected]> | 2023-06-03 13:16:32 +0200 |
commit | bbe755fb69f3c42cb79d19d10a58fda54aabfd42 (patch) | |
tree | 7fda5af79fe8e3fd248cbedd6c81290c059fddf5 /src/machine/machine_rp2040_pwm.go | |
parent | 635d32270352ab902fad415728a7ded510424dd3 (diff) | |
download | tinygo-bbe755fb69f3c42cb79d19d10a58fda54aabfd42.tar.gz tinygo-bbe755fb69f3c42cb79d19d10a58fda54aabfd42.zip |
fix bug in rp2040 SetPeriod implementation
Diffstat (limited to 'src/machine/machine_rp2040_pwm.go')
-rw-r--r-- | src/machine/machine_rp2040_pwm.go | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/machine/machine_rp2040_pwm.go b/src/machine/machine_rp2040_pwm.go index cc2f2f5d9..f72d6dd03 100644 --- a/src/machine/machine_rp2040_pwm.go +++ b/src/machine/machine_rp2040_pwm.go @@ -260,7 +260,9 @@ func (pwm *pwmGroup) setPeriod(period uint64) error { maxTop = math.MaxUint16 // start algorithm at 95% Top. This allows us to undershoot period with prescale. topStart = 95 * maxTop / 100 - milliseconds = 1_000_000_000 + nanosecond = 1 // 1e-9 [s] + microsecond = 1000 * nanosecond // 1e-6 [s] + milliseconds = 1000 * microsecond // 1e-3 [s] // Maximum Period is 268369920ns on rp2040, given by (16*255+15)*8*(1+0xffff)*(1+1)/16 // With no phase shift max period is half of this value. maxPeriod = 268 * milliseconds |