Skip to content

Commit 77b0c76

Browse files
committed
raspberrypi: audiopwmout: simple fix for #5092
1 parent 02bbb20 commit 77b0c76

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ void common_hal_audiopwmio_pwmaudioout_play(audiopwmio_pwmaudioout_obj_t *self,
175175
uint32_t best_error = system_clock;
176176

177177
for (uint32_t denominator = 0xffff; denominator > 0; denominator--) {
178-
uint32_t numerator = (denominator * sample_rate) / system_clock;
179-
uint32_t remainder = (denominator * sample_rate) % system_clock;
178+
uint32_t numerator = ((uint64_t)denominator * sample_rate) / system_clock;
179+
uint32_t remainder = ((uint64_t)denominator * sample_rate) % system_clock;
180180
if (remainder > (system_clock / 2)) {
181181
numerator += 1;
182182
remainder = system_clock - remainder;

0 commit comments

Comments
 (0)