From fe20079300e19e21b64ea428c019ca729670627f Mon Sep 17 00:00:00 2001 From: soypat Date: Thu, 8 Jan 2026 19:14:30 -0300 Subject: [PATCH] rp2: prevent pwm Period method overflow --- src/machine/machine_rp2_pwm.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/machine/machine_rp2_pwm.go b/src/machine/machine_rp2_pwm.go index 772811e36..1a765947b 100644 --- a/src/machine/machine_rp2_pwm.go +++ b/src/machine/machine_rp2_pwm.go @@ -153,7 +153,7 @@ func (p *pwmGroup) Period() uint64 { top := p.getWrap() phc := p.getPhaseCorrect() Int, frac := p.getClockDiv() - return (16*uint64(Int) + uint64(frac)) * uint64((top+1)*(phc+1)*1e9) / (16 * freq) // cycles = (TOP+1) * (CSRPHCorrect + 1) * (DIV_INT + DIV_FRAC/16) + return (16*uint64(Int) + uint64(frac)) * uint64((top+1)*(phc+1)) * uint64(1e9) / (16 * freq) // cycles = (TOP+1) * (CSRPHCorrect + 1) * (DIV_INT + DIV_FRAC/16) } // SetInverting sets whether to invert the output of this channel.