-
Notifications
You must be signed in to change notification settings - Fork 511
Description
Hello.
First, I should mention that I'm not an I2S expert, so I might be missing something fundamental. I'm trying to receive audio data from a V4220M/CS4220 codec using the Arduino-Pico I2S library, but I'm experiencing issues with the input data. Interestingly, I2S output to the same codec works perfectly fine.
Hardware Setup:
- Raspberry Pi Pico (RP2040)
- V4220M/CS4220 Audio Codec (I've tested multiple modules, so I don't believe it's a hardware failure)
- Connections:
- GPIO20 -> SCLK (pin5)
- GPIO21 -> LRCK (pin4)
- GPIO15 -> SDIN (pin9)
- GPIO18 -> MCLK (pin3)
- GPIO19 -> RST (pin27)
Clock Configuration:
- Sample Rate: 48kHz
- BCLK: 3.072MHz
- MCLK: 12.288MHz (256Fs)
- LRCK: 48kHz
(confirmed with oscilloscope)
Code:
I2S i2s(INPUT);
const int32_t sampleRate = 48000;
void setup() {
// V4220M reset sequence
pinMode(PIN_I2S_RST, OUTPUT);
digitalWrite(PIN_I2S_RST, LOW);
delay(10);
digitalWrite(PIN_I2S_RST, HIGH);
delay(50);
// I2S configuration
i2s.setBCLK(PIN_I2S_BCLK);
i2s.setDATA(PIN_I2S_DIN);
i2s.setBitsPerSample(32);
i2s.setBuffers(4, 32);
i2s.setMCLK(PIN_I2S_MCLK);
i2s.setMCLKmult(256);
if (!i2s.setSysClk(sampleRate)) {
Serial.println("Failed to set system clock!");
while(1);
}
if (!i2s.begin(sampleRate)) {
Serial.println("Failed to start I2S!");
while(1);
}
}The received data shows an unusual pattern:
Time,Raw,Hex,Voltage,Debug
82087,14,0x00000E,0.000,0x00000ED0
82087,262141,0x03FFFD,0.062,0x03FFFD74
82087,7,0x000007,0.000,0x00000728
82088,262121,0x03FFE9,0.062,0x03FFE9A8
The data seems to alternate between very small values (0x00000X) and larger values (0x03FFXX), which doesn't look like normal audio data. I've tried:
- Different bit depths (24/32)
- Different I2S formats (DIF0/DIF1 configurations on V4220M)
- Checking clock signals with oscilloscope
- Multiple codec chips to rule out hardware issues
The fact that output works perfectly suggests the clock setup is correct. Am I missing something important in the I2S input configuration? Since I'm relatively new to I2S, there might be some fundamental concept I'm overlooking.
Any help or suggestions would be greatly appreciated!