From 69f18ae7491f24f471bc8dedbd515e1f43ea535e Mon Sep 17 00:00:00 2001 From: TMRh20 Date: Tue, 22 Oct 2024 19:03:55 -0600 Subject: [PATCH] nRF52: Stereo mode not set back to mono --- .../Platforms/NRF52/NRF52_PDM_PWMTest/NRF52_PDM_PWMTest.ino | 2 +- src/NRF52840/AutoAnalogAudio.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/Platforms/NRF52/NRF52_PDM_PWMTest/NRF52_PDM_PWMTest.ino b/examples/Platforms/NRF52/NRF52_PDM_PWMTest/NRF52_PDM_PWMTest.ino index 138c0da..8e337b6 100644 --- a/examples/Platforms/NRF52/NRF52_PDM_PWMTest/NRF52_PDM_PWMTest.ino +++ b/examples/Platforms/NRF52/NRF52_PDM_PWMTest/NRF52_PDM_PWMTest.ino @@ -17,7 +17,7 @@ void setup() { void loop() { aaAudio.getADC(320); // Get 320 Samples from the ADC - for (int i = 0; i < 320; i++) { // Copy them into the DAC Buffer and change from signed to unsigned ( + 0x8000) + for (int i = 0; i < 320; i++) { // Copy them into the DAC Buffer aaAudio.dacBuffer16[i] = (uint16_t)(aaAudio.adcBuffer16[i]); } aaAudio.feedDAC(0,320); // Feed the DAC with the ADC data diff --git a/src/NRF52840/AutoAnalogAudio.cpp b/src/NRF52840/AutoAnalogAudio.cpp index e7b2082..c202260 100644 --- a/src/NRF52840/AutoAnalogAudio.cpp +++ b/src/NRF52840/AutoAnalogAudio.cpp @@ -132,6 +132,8 @@ void AutoAnalog::setSampleRate(uint32_t sampRate, bool stereo){ if(stereo){ NRF_I2S->CONFIG.CHANNELS = I2S_CONFIG_CHANNELS_CHANNELS_STEREO << I2S_CONFIG_CHANNELS_CHANNELS_Pos; + }else{ + NRF_I2S->CONFIG.CHANNELS = I2S_CONFIG_CHANNELS_CHANNELS_LEFT << I2S_CONFIG_CHANNELS_CHANNELS_Pos; } if(sampRate <= 16000){