raspberrypi: audiopwmout: simple fix for #5092

This commit is contained in:
Jeff Epler 2021-08-24 12:11:22 -05:00
parent 02bbb204e0
commit 77b0c76a37

View File

@ -175,8 +175,8 @@ void common_hal_audiopwmio_pwmaudioout_play(audiopwmio_pwmaudioout_obj_t *self,
uint32_t best_error = system_clock;
for (uint32_t denominator = 0xffff; denominator > 0; denominator--) {
uint32_t numerator = (denominator * sample_rate) / system_clock;
uint32_t remainder = (denominator * sample_rate) % system_clock;
uint32_t numerator = ((uint64_t)denominator * sample_rate) / system_clock;
uint32_t remainder = ((uint64_t)denominator * sample_rate) % system_clock;
if (remainder > (system_clock / 2)) {
numerator += 1;
remainder = system_clock - remainder;