Starting from evkmimxrt685_i2s_dma_record_playback sample project with SDK, I try to run the same audio sampling functionality by codec WM8904, but not in 16 bits, but in 24 bits (2channels, 48kHz). I managed to get the situation where codec itself works in 24 bits. But the DMA transfer only allows me to transfer one channel. (one channel mode, MONO) When I turn on second channel (STEREO) DMA sends me only half of data (probably I get every second sample). Can the I2S_dma driver only transfer 32 bits from FIFO to my buffer? But is there any way to send 2x 32 bits each?
I have the same problem with I2S_dma if you use 48-bits packed option (2x24bits). I get every second sample.
Solved! Go to Solution.
Hi Kerry. Indeed, taking the data from the debugger window directly, the results are correct. No zeros. Pure triangle waveforms. It looks like the problem really lies in the printf function. Hence, the conclusions were wrong. The sample project with 24-bit 2 channels after my amendment works correctly! I close the thread. Thank you for help.
Hi adrian_klimczak,
Thanks so much for your detailed reply and the code, and sorry for my later reply!
I also checked your code and test it on my side.
You mentioned that: we get half data for left and half data for right channel
But from the test result:
Take the data as an example:
L: 51,255,255,0; = 0XFFFF33
R:33,254,255,0; = 0XFFFE21
L:243,253,255,0; = 0XFFFDF3
R:121,253,255,0;= 0XFFFE79
All the related channel is 24bit, could you tell me why you mention: get half data for left and half data for right channel?
From the result, it is the 24 bit, not just half data.
Sorry, I still don't very clear about your question details, do you want the DMA send your just 24bits data directly, instead of the 32bit which also contains one byte 0X00?
Best Regards,
Kerry
Thank you for your reply.
What you are stating is correct, but this is not the issue we are experiencing. Let me try to elaborate a bit more about the issue we are experiencing.
What you are showing us on your image is the first part of the signal, which is valid. If you look at the last part of the buffer, it would be lots of zeros.
0,0,0,0,
0,0,0,0,
0,0,0,0,
0,0,0,0,
0,0,0,0,
0,0,0,0,
0,0,0,0,
If you look at the attached "Screenshot 2020-10-20 at 16.56.42.png" in one of my replies, you will see that about half of the samples (50 samples) give three triangles (triangular signal) and from about sample 51st to sample 100th samples are flat with some small anomalies, while it should continue with the triangular signal.
Our signal comes from function generator, using triangular wave.
Buffer is 100 samples per channel (int32 values) -> 4 bytes per sample (400 uint8 values) per channel = 800 uint8 values in total for 2 channels. First 4 bytes is left channel then 4 bytes for right channel.
For example:
29,81,231,0, // Left Channel
86,34,173,0, // Right Channel
181,232,203,0, // Left Channel
164,219,204,0, // Right Channel
Please look at the second half of the buffer to verify that it has lots of zeros. Can you see those zeroes? If not, what is your input, is it function generator, wav file, static array?
Hi adrian_klimczak,
So sorry for my later reply, really a lot of cases in the testing queue.
I didn't add any input source when I test your project in the last time.
Thanks for letting me know that your input the triangular wave, could you please tell me your detail triangular wave from your function generator? 48Khz? Can you give me your photo about your input triangular wave? I will also find one function generator and test it like you.
Please also let me know your wave connection to the RT685-EVK board, and give me the photo.
I need to test it, and try to reproduce your issues, then I can check more detail with our expert.
Please let me know more details to reproduce your issues, the board connection with your signal source input, and your input source details, amplitude and the frequence.
Best Regards,
Kerry
Hi Kerry.
We use a normal function generator which is connected directly to the MIMXRT685-EVK devboard, via J3 connector. Parameters of the signal from generator:
1. Triangle mode,
2. output voltage 1.4Vpp,
3. frequency 375Hz.
At the input (J3) and output (J4) of the devboard, I connect an oscilloscope probe for viewing. (ch1.output signal, ch2.input signal) I attach a sample oscillogram of such measurement.
Best Regards,
Slawek
Hi slawek_zabielsk,
When you use the generator Triangle mode generate the wave, then it will output 2 wire, GND, and the wave from the generator, how you connect it to the J3?
How do you connect the signal between the generator and the J3?
Because I don't have the connector, then I need to connect the generator two-pin to the EVK circuit directly. Then I want to know your detailed connection and I can test it.
Best Regards,
Kerry
Hi Kerry.
I connect the generator via my Scarlet 2i2 sound card. Then I connect the output of the card to the devboard input. To do this I use two cables:
1. Coaxial -> JACK 1/2" - connection of the generator output with input 1 of the music card
2. JACK 3.5mm plug -> JACK 3.5mm plug - connection of the sound card output with NXP devboard input (J3)
Since the music card output is JACK 1/2" socket, I additionally use a 1/2" JACK adapter on the 3.5mm JACK shown in the picture. I connect the oscilloscope probe to the devboard output using a second cable type 2.
Best Regards,
Slawek
Hi slawek_zabielsk,
I don't have your test wire, I just have these tools and wire:
So, if I need to use the function generator tool, I may need to input two channel, then connect one signal to LININL_JACK, another to LININR_JACK.
Could you please give me your oscilloscope wave in LININL_JACK and LININR_JACK?
Today, I borrow one following 3.5mm wire from my colleagues in the other department:
Then use the PC to connect this wire, and connect to the board J3, and play the music, I also use the headphone to connect J4 to hear the loopback.I find the music is correct, but your printf data is really still have the issues that half data is 0, but the song should no so much 0s, So I still need to check the detail reason with our internal side, maybe I still also need to check input the directly fixed wave, then printf the data, and then talk with our internal expert about your issues
Now, please share me your oscilloscape wave about two channel, one channel is LININL_JACK, another channel is LININR_JACK, I will also try to test the same wave.
The following is my test result with the music:
Configure WM8904 codec
Configure I2S
Setup digital loopback
212,185,255,0;
92,69,0,0;
58,162,255,0;
64,10,0,0;
41,238,255,0;
2,255,255,0;
198,47,0,0;
174,27,0,0;
194,166,0,0;
155,69,0,0;
51,202,0,0;
77,160,0,0;
252,235,0,0;
164,219,0,0;
104,233,0,0;
66,190,0,0;
193,128,0,0;
254,146,0,0;
44,44,0,0;
167,41,0,0;
84,19,0,0;
70,33,0,0;
149,33,0,0;
128,4,0,0;
158,17,0,0;
168,199,255,0;
103,237,255,0;
146,167,255,0;
228,241,255,0;
173,139,255,0;
234,220,255,0;
133,118,255,0;
109,125,255,0;
20,254,254,0;
34,82,255,0;
112,174,254,0;
215,55,255,0;
129,163,254,0;
110,38,255,0;
191,159,254,0;
99,74,255,0;
47,62,255,0;
104,30,255,0;
143,255,254,0;
175,217,254,0;
255,196,254,0;
97,251,254,0;
168,183,254,0;
112,235,254,0;
108,163,254,0;
102,195,254,0;
201,204,254,0;
241,209,254,0;
43,3,255,0;
116,161,254,0;
232,42,255,0;
19,172,254,0;
87,88,255,0;
247,246,254,0;
155,128,255,0;
164,16,255,0;
84,175,255,0;
141,254,254,0;
93,83,255,0;
114,151,255,0;
19,193,255,0;
161,159,255,0;
96,216,255,0;
224,181,255,0;
188,17,0,0;
229,158,255,0;
8,16,0,0;
217,121,255,0;
168,217,255,0;
27,136,255,0;
62,140,255,0;
19,107,255,0;
241,147,255,0;
197,95,255,0;
71,130,255,0;
227,106,255,0;
178,180,255,0;
188,115,255,0;
34,231,255,0;
95,141,255,0;
123,208,255,0;
10,142,255,0;
66,188,255,0;
33,116,255,0;
84,113,255,0;
234,159,255,0;
165,90,255,0;
186,211,255,0;
212,116,255,0;
254,210,255,0;
164,129,255,0;
95,226,255,0;
13,184,255,0;
144,159,255,0;
93,131,255,0;
225,119,0,8;
176,28,8,0;
225,119,0,8;
64,28,8,0;
0,0,0,0;
0,0,0,0;
4,1,0,0;
3,0,0,0;
64,0,0,0;
4,0,0,0;
27,113,0,8;
40,26,8,0;
0,0,0,0;
48,19,8,0;
40,3,0,0;
48,19,8,0;
2,0,0,0;
4,0,0,0;
128,25,8,0;
48,19,8,0;
40,3,0,0;
48,19,8,0;
0,0,0,0;
0,2,0,0;
48,19,8,0;
40,3,0,0;
80,11,8,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,54,110,1;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,112,16,64;
240,25,8,0;
1,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
0,0,0,0;
Hi slawek_zabielsk,
Seems the printf result have issues, do you debug your code, and check the s_Buffer_copy array data directly?
I find there are not so much 0s.
Hi Kerry. Indeed, taking the data from the debugger window directly, the results are correct. No zeros. Pure triangle waveforms. It looks like the problem really lies in the printf function. Hence, the conclusions were wrong. The sample project with 24-bit 2 channels after my amendment works correctly! I close the thread. Thank you for help.
Hi adrian_klimczak,
Please share me your modified project directly, and let me know your testing IDE, I need to test it directly and check it on my side.
Please also tell me how do you get your attached pictures?
Best Regards,
Kerry
Hi kerryzhou,
Thank you for your quick response.
Please, see the modified sample project attached: evkmimxrt685_i2s_dma_record_playback.zip.
We are using MCUExpresso IDE.
To get the attached picture:
Changes we made to sample project:
.bitWidth = kWM8904_BitWidth16 ->
.bitWidth = kWM8904_BitWidth24
Please, let me know if your require any more information.
We are working with Slawek on the same project in the same team, therefore let me fill the details to help us receive an answer to this problem.
In order to get 24 bits for just one channel we did the following modifications to the "evkmimxrt685_i2s_dma_record_playback" sample project:
After doing these changes we noticed that we still get 16 bit data length values, therefore we modified fsl_wm8904.c file, line 85,
from
result = WM8904_ModifyRegister(handle, WM8904_AUDIO_IF_1, 0x000C | (1U << 6U), format->bitWidth);
to
result = WM8904_ModifyRegister(handle, WM8904_AUDIO_IF_1, 0x000C | (1U << 6U), (format->bitWidth)<<2u);
After this change, we started receiving 24 bit length data however just for one channel. If we set:
config->oneChannel = false
Then, we get half data for left and half data for right channel. Please see attached .png file.
Are we configuring something wrong?
Hi adrian_klimczak,
Please send me your modified project directly, I need to check your code details, whether you modified the correct points.
Best Regards,
Kerry
Hi All,
Sorry for the later reply.
Please give me more time to analyze your issues, I will give your feedback ASAP, please keep patient, thanks.
Best Regards,
Kerry