From f31a8319b0ac324415f91906bfdca5685f9cbd4d Mon Sep 17 00:00:00 2001 From: TMRh20 Date: Mon, 4 Nov 2024 13:45:54 -0600 Subject: [PATCH] nRF52: I2S Fix for double-buffering - Move TASKS_START down to after the buffers are loaded. Not sure if it matters... --- src/NRF52840/AutoAnalogAudio.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/NRF52840/AutoAnalogAudio.cpp b/src/NRF52840/AutoAnalogAudio.cpp index 3c321ac..07cd847 100644 --- a/src/NRF52840/AutoAnalogAudio.cpp +++ b/src/NRF52840/AutoAnalogAudio.cpp @@ -268,7 +268,7 @@ void AutoAnalog::getADC(uint32_t samples){ started = true; }else{ while(NRF_I2S->EVENTS_RXPTRUPD == 0){} - } + } if(adcWhichBuf == 0){ NRF_I2S->RXD.PTR = (uint32_t)&adcBuf0[0]; @@ -288,11 +288,7 @@ void AutoAnalog::getADC(uint32_t samples){ } NRF_I2S->EVENTS_RXPTRUPD = 0; - if(started){ - NRF_I2S->TASKS_START = 1; - } - - + if(adcBitsPerSample == 24){ if( NRF_I2S->CONFIG.SWIDTH != I2S_CONFIG_SWIDTH_SWIDTH_24BIT << I2S_CONFIG_SWIDTH_SWIDTH_Pos){ NRF_I2S->CONFIG.SWIDTH = I2S_CONFIG_SWIDTH_SWIDTH_24BIT << I2S_CONFIG_SWIDTH_SWIDTH_Pos; @@ -319,7 +315,10 @@ void AutoAnalog::getADC(uint32_t samples){ } adcWhichBuf = !adcWhichBuf; - + if(started){ + NRF_I2S->TASKS_START = 1; + } + }else if(useI2S == 0){ while(!adcReady){__WFE();};