I2S with MCLK input #1765
-
I'm working with TI PCM1802 ADC, which needs an MCLK/SCLK signal at a frequency multiple of fs. Why is the MCLK functionality only available to I2S output? Is there any way to enable MCLK for input I2S as well? |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 34 replies
-
No reason other than nobody thought it would be needed. Can you try removing the arduino-pico/libraries/I2S/src/I2S.cpp Line 137 in 5678bb9 |
Beta Was this translation helpful? Give feedback.
-
I can confirm that removing this check works (after deleting the pre-cached I2S.cpp.o and I2S.cpp.d [I think they were] files). My use case is simply to provide the MCLK to use the Pico with a PCM1808 ADC module, which requires an external master clock at a minimum. Now I've got a signal, just need to figure out how to send it back as a line input over USB... |
Beta Was this translation helpful? Give feedback.
-
https://github.com/earlephilhower/arduino-pico/blob/master/docs/i2s.rst says;
so try;
though I'm not sure if there's enough RAM for that many buffers, so maybe try a smaller number for the first parameter, but perhaps keep the second one, bufferWords, as 1000... or maybe 2000, since it says that's the number of 32 bit words, not the number of samples? I'm not at all sure how to choose the number of buffers, and there doesn't seem to be enough information to go on to decide how to choose their size, but setting the size to zero seems wrong. |
Beta Was this translation helpful? Give feedback.
-
Also, though not directly related to the data you're showing, are you sure the input voltage is in the allowed range? From the TI datasheet:
Since your connection picture shows RCA/phono sockets wired to the i2s module, it looks like you might feed it an audio signal that can be positive or negative with respect to ground, which is not what that chip wants. Maybe decouple the inputs with capacitors in series between the RCA sockets and the input pins, and bias the inputs to Vcc/2 with two resistors - one to ground and one to Vcc. The analog input impedance of the chip is 60kΩ, according to the datasheet, so maybe try 100k or 1M for the two bias resistors, and decoupling capacitors somewhere in the range of 1uF to 2uF. You can get non-polarised electrolytic capacitors or MLCC (multilayer ceramic capacitors) in that range, though it seems common to use an electrolytic capacitor with the + facing the socket. |
Beta Was this translation helpful? Give feedback.
-
I may well be misunderstanding, but it seems you should be shifting by 8 bits, not 9. I assume this is just to get the sign bit in the right place. From the arduino-pico/docs/i2s.rst documentation:
I don't understand how to go about choosing the number of buffers or the buffer size either. I can see how double buffering could help, for reading in real time out of sync with the i2s transfer, but I'm not clear why lots of little buffers is better than two larger ones. |
Beta Was this translation helpful? Give feedback.
-
I can't tell which trace is blue and which is green, but if BCK is the shorter one / lowest signal, with four pulses shown, then yes, that looks inverted. The timing diagram shows BCK changing from high to low as LRCK changes state (either way) in both formats, so even if LRCK was inverted, what your scope shows still doesn't match the diagram. I can't tell from that whether the data is being left justified or not. If you could do it again with negative inputs that would make it clearer - the MSB would then be set, making it clearer where the data starts. Even so, It seems more likely that clocking the data on the wrong edge of BCK, because it's inverted, is the problem. |
Beta Was this translation helpful? Give feedback.
No reason other than nobody thought it would be needed.
Can you try removing the
_isOutput
check herearduino-pico/libraries/I2S/src/I2S.cpp
Line 137 in 5678bb9