8000 Check for PDMIn DMA getting stuck. · adafruit/circuitpython@218930d · GitHub
[go: up one dir, main page]

Skip to content

Commit 218930d

Browse files
committed
Check for PDMIn DMA getting stuck.
1 parent ba7e0e2 commit 218930d

File tree

1 file changed

+11
-0
lines changed
  • ports/atmel-samd/common-hal/audiobusio

1 file changed

+11
-0
lines changed

ports/atmel-samd/common-hal/audiobusio/PDMIn.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,18 @@ uint32_t common_hal_audiobusio_pdmin_record_to_buffer(audiobusio_pdmin_obj_t* se
392392
break;
393393
}
394394
// Wait for the next buffer to fill
395+
uint32_t wait_counts = 0;
396+
#ifdef SAMD21
397+
#define MAX_WAIT_COUNTS 1000
398+
#endif
399+
#ifdef SAMD51
400+
#define MAX_WAIT_COUNTS 6000
401+
#endif
395402
while (!event_interrupt_active(event_channel)) {
403+
if (wait_counts++ > MAX_WAIT_COUNTS) {
404+
// Buffer has stopped filling; DMA may have missed an I2S trigger event.
405+
break;
406+
}
396407
#ifdef MICROPY_VM_HOOK_LOOP
397408
MICROPY_VM_HOOK_LOOP
398409
#endif

0 commit comments

Comments
 (0)
0