From 00b8a25284eee9bc286bfc01623f55747bae9a72 Mon Sep 17 00:00:00 2001 From: Sandeep Mistry Date: Wed, 29 Sep 2021 16:01:44 -0400 Subject: [PATCH] Add wait for new samples loop in hello analog/pdm microphone examples --- examples/hello_analog_microphone/main.c | 3 +++ examples/hello_pdm_microphone/main.c | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/hello_analog_microphone/main.c b/examples/hello_analog_microphone/main.c index ba5a890..ab9d32c 100644 --- a/examples/hello_analog_microphone/main.c +++ b/examples/hello_analog_microphone/main.c @@ -68,6 +68,9 @@ int main( void ) } while (1) { + // wait for new samples + while (samples_read == 0) { tight_loop_contents(); } + // store and clear the samples read from the callback int sample_count = samples_read; samples_read = 0; diff --git a/examples/hello_pdm_microphone/main.c b/examples/hello_pdm_microphone/main.c index 4618049..0436824 100644 --- a/examples/hello_pdm_microphone/main.c +++ b/examples/hello_pdm_microphone/main.c @@ -74,7 +74,10 @@ int main( void ) } while (1) { - // store and clear the samples read from the callback + // wait for new samples + while (samples_read == 0) { tight_loop_contents(); } + + // store and clear the samples read from the callback int sample_count = samples_read; samples_read = 0;