I2S - support for 64 bit setBitsPerSample() -- TLV320ADC5140 #1253
-
Hi The project requires 4 analogue microphones. I've started working with the TLV320ADC5140 Quad-Channel Audiuo ADC. I think to support 4 analog mics the TLV320ADC5140 in I2S mode uses 2x 32 bits left channel and 2x 32 bits right channel. I'm think that this is the same 64 bits per sample. Does anyone know if it's possible to modify the I2S library to support this? Many thanks in advance |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 9 replies
-
It's a hack, but I think it's not too difficult as long as you yourself keep track of the channel layout. Note that this is off the top of my head, but it should get you going... In the I2S lib, comment out the sanity check arduino-pico/libraries/I2S/src/I2S.cpp Lines 77 to 79 in 7aa1c08 In your app use |
Beta Was this translation helpful? Give feedback.
-
Many thanks for the quick response. I modified the I2S.cpp setBitsPerSample(int bps) and tested with the following 64 bit per channel calls:
i2s0.setBitsPerSample(64) produces a 2.048MHz clock 32 bits per channel i2s0.setBitsPerSample(32) produces a 1.024MHz clock 32 bits per channel The modified I2S.cpp is definitly being used - if I put an error in the I2S source then the build fails Any ideas? Many thanks John |
Beta Was this translation helpful? Give feedback.
-
Many thanks for helping with this - sorry I'm not yet up to speed with the pico pio I tried the mods. as follows I2S.cpp
And added a function to pio_i2s_pio
The BLCK is still 32 bits per LRCLK
value 0-31 |
Beta Was this translation helpful? Give feedback.
-
I'm learning but nowhere up to speed with RP2040 pio programming - many thanks for all your help and patience. Suggested changes does create the correct number of frame bits - 64 Left and 64 Right pio_i2s.pio
Current modified library Current test ino Debug out when driving DIN with a un-syncronised square wave of similar frequency to the frame rate. The data is I think sane - I only ever see odd numbers on the left and even on the right but the logic analayser sees similar behaviour. Using the above test code there are missing groups of data frames every so often - I didn't know if this was an issue from the pio code or the serial debug code. So I tried extracting the data first into a local buffer and then printing the buffer. With i2s0.setBuffers(16,128,0) I get 0x100 samples then empty data. I suspect the DMA is empty? but I failed to check something? Increasing the bufferWords in i2s0.setBuffers(16,256,0) fills adcOutData - I must be miss understanding something here. However there are no missing sets of samples until the end of the i2s0.setBuffers setting and the results are consistent. |
Beta Was this translation helpful? Give feedback.
I'm learning but nowhere up to speed with RP2040 pio programming - many thanks for all your help and patience.
Suggested changes does create the correct number of frame bits - 64 Left and 64 Right
pio_i2s.pio