Skip to content

Commit c95cbea

Browse files
committed
raspberrypi: PDMIn: Fix sample rate check.
The "actual frequency" is the PIO frequency, which is twice the audio clock.
1 parent 86bb6db commit c95cbea

File tree

1 file changed

+1
-1
lines changed
  • ports/raspberrypi/common-hal/audiobusio

1 file changed

+1
-1
lines changed

ports/raspberrypi/common-hal/audiobusio/PDMIn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ void common_hal_audiobusio_pdmin_construct(audiobusio_pdmin_obj_t *self,
6464
PIO_FIFO_TYPE_DEFAULT,
6565
PIO_MOV_STATUS_DEFAULT, PIO_MOV_N_DEFAULT);
6666
uint32_t actual_frequency = common_hal_rp2pio_statemachine_get_frequency(&self->state_machine);
67-
if (actual_frequency < MIN_MIC_CLOCK) {
67+
if (actual_frequency < 2 * MIN_MIC_CLOCK) { // 2 PIO samples per audio clock
6868
mp_raise_ValueError(MP_ERROR_TEXT("sampling rate out of range"));
6969
}
7070

0 commit comments

Comments
 (0)