Skip to content

Commit 4e4d795

Browse files
authored
Merge pull request adafruit#916 from dhalbert/pdmin_hack_fix
Check for PDMIn DMA getting stuck.
2 parents c01ce17 + 218930d commit 4e4d795

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy