This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Streaming audio data from ADC with I2S

Hello,

I´m working on my audio project and I try to stream some audio data (currently a 1 kHz square wave signal with 3.3 V peak) over I2S. The audio signal is sampled by an ADC in the free-running mode.

The code from above will give a pretty poor signal when I use the ADC.

I have tried to figure out the reason for this and replaced the line

with

to produce data from a ramp signal and the signal looks much better.

So it looks like the problem is based on the ADC. I have tried to use two buffers to use the same swapping buffer system as in the I2S example.

How can I improve this result?

  • Hello,

    I try to stream some audio data (currently a 1 kHz square wave signal with 3.3 V peak) over I2S. The audio signal is sampled by an ADC in the free-running mode.
    So it looks like the problem is based on the ADC. I have tried to use two buffers to use the same swapping buffer system as in the I2S example.

    How can I improve this result?

    Is there a particular reason why you are not using the nRF52832's I2S peripheral directly for this?
    If there is, please let me know about your application requirements and constraints, so I may advice you on how to increase the performance according to this.
    If there is an option to instead use the I2S peripheral directly then this is what I would advice, as this should give you a great performance increase compared to what you are seeing now, without involving the SAADC peripheral.

    If you are not sure how to use the I2S peripheral it may be helpful to take a look at the I2S loopback example from the nRF5 SDK which demonstrates both output and input using the peripheral.

    Best regards,
    Karl

  • Hi Karl,

    Is there a particular reason why you are not using the nRF52832's I2S peripheral directly for this?

    what do you mean by this question? I already use the I2S peripheral to stream out the data from the nRF52832, but the data is generated by an ADC that samples some sort of device to get the audio data. In my setup, the "device" is a 3.3 V square wave generator, but it should get replaced with an analog microphone. I only use the generator to get a known signal.

    Feel free to ask if you have additional questions :)

  • Kampino said:
    what do you mean by this question? I already use the I2C peripheral to stream out the data from the nRF52832

    I meant the I2S, not I2C / TWI - I was of the understanding from your initial ticket that you were using the SAADC to read (through sampling) a I2S signal, is this not the case?
    If so, I would advice that you make use of the nRF52832's I2S peripheral directly, instead of reading it with the SAADC.

    I posed the question in case there was a constraint or requirement by your application that forced you to use the SAADC instead of the I2S peripheral to read the incoming I2S data stream, that I might not be aware of. If there is not, then I think we should look at switching to using the I2S peripheral instead :) 
    How do you think this would fit with your application?

    Best regards,
    Karl

  • Hi Karl,

    sorry I meant I2S (not I2C as you mentioned - I have fixed it). Please take a look at the overview drawing.


    The "Microphone" is replaced by my squarewave generator, but the idea is that the nRF52 will sample the analog input signal with a SAADC and transmit the sampled signal over I2S to my master.

    But it turns out that the signal quality on my master is very bad (see the screenshot) when I use the SAADC to sample the analog audio signal and use the result as the I2S data. The quality is good when I don´t use the SAADC and generate the I2S data "on the fly" by the CPU (in this case a ramp).

    So I think that the conversion with the ADC and the transmission over I2S runs into some sort of error (i. e. overwriting data while they got transmitted, etc.), but I can not figure out the problem.

    Hope it is clear now :)

  • Hello again,

    Thank you for your patience with this.

    Kampino said:
    sorry I meant I2S (not I2C as you mentioned - I have fixed it). Please take a look at the overview drawing.

    Thank you for clarifying this with the drawing - this does indeed make the overview a lot more clear! :) 

    Kampino said:
    The "Microphone" is replaced by my squarewave generator, but the idea is that the nRF52 will sample the analog input signal with a SAADC and transmit the sampled signal over I2S to my master.

    Sure, this is a good way to simulate it for testing.
    Could you perhaps set the generator to a sine-wave, and share the SAADC's raw measurements of this with me? This should help us pinpoint the issue.

    Kampino said:
    So I think that the conversion with the ADC and the transmission over I2S runs into some sort of error (i. e. overwriting data while they got transmitted, etc.), but I can not figure out the problem.

    Yes, from your testing it sounds like it might be an issue with the SAADC usage. However, I do not immediately see what that might be what might be causing this. Is the code you shared earlier the complete code that is running, or only a section of a larger program?

    Best regards,
    Karl

1 2 3 4 5