Skip to content

Commit fe20079

Browse files
soypatdeadprogram
authored andcommitted
rp2: prevent pwm Period method overflow
1 parent 068d7c1 commit fe20079

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/machine/machine_rp2_pwm.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func (p *pwmGroup) Period() uint64 {
153153
top := p.getWrap()
154154
phc := p.getPhaseCorrect()
155155
Int, frac := p.getClockDiv()
156-
return (16*uint64(Int) + uint64(frac)) * uint64((top+1)*(phc+1)*1e9) / (16 * freq) // cycles = (TOP+1) * (CSRPHCorrect + 1) * (DIV_INT + DIV_FRAC/16)
156+
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)
157157
}
158158

159159
// SetInverting sets whether to invert the output of this channel.

0 commit comments

Comments
 (0)