This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

I2S programming on nRF52840

Hi,

I am trying to write 16bit, 16Khz, 2 channel PCM data to I2S. nRF52840 DK board is connected to speaker via I2S player/decoder board. I am able to hear audio but it is not that good. Looks bit of noisy.

I have seen I2S loopback example in SDK 15. Based on that I have written this new application. I want to understand how frequently I need to write to I2S buffers for above configuration. Also is there any delay we need to give after writing some samples.

Following is code sinnpet from I2S loopback example in which I have some questions:

283 do {
284 // Wait for an event.
285 __WFE();
286 // Clear the event register.
287 __SEV();
288 __WFE();
289
290 if (mp_block_to_fill)
291 {
292 prepare_tx_data(mp_block_to_fill);
293 mp_block_to_fill = NULL;
294 }
295 if (mp_block_to_check)
296 {
297 check_rx_data(mp_block_to_check);
298 mp_block_to_check = NULL;
299 }
300 } while (m_blocks_transferred < BLOCKS_TO_TRANSFER);

1. Why we need to wait for event

2. Since we are not waiting to finish samples here, how much samples I2S can buffer internally. Can it be overriden incase we are write too fast.

3. Can we drive I2S when using softdevice? Do we need __WFE() in case of soft device?

Thanks

Rahul

Parents Reply Children
Related