This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Glitch in analog audio output when using I2S module

Hello.

I'm using the NRF52832 with I2S module connected to TLV320DAC from TI. I've configured the DAC and I2S module successfully. I'm getting audio output (simple sine wave read from a table) but there is an impulse glitch in the audio signal. The glitch appears to occur at the end of every I2S buffer send. When I set the I2S TX buffer size to 250 samples, I see a glitch in the audio at the corresponding time interval. For example, 250 buffer size at 41666 sample rate, causes a glitch in the audio every 0.006 seconds. When I increase the I2S buffer size, the glitch period increases correspondingly.

I've checked my sine table interpolation algorithm. It looks good. I believe the problem is with the NRF52832 and not the DAC. The I2S buffer size is the only variable which seems to affect the audio glitch. Oh, I also tried using I2S slave mode where I program the DAC to send the I2S clocks to the NRF chip. That did not change the glitch though.

I recorded the audio output in Audacity. Take a look at the waveform and frequency spectrum...

\

Parents Reply Children
  • Another observation. It seems like the last sample the buffer is carried over to the next buffer. The sample value at the glitch appears to be the value which should be at the previous glitch location. I still don't know if this is a bug in my code or possibly the I2S driver.

  • Looks like it's trying to play a sample back in time (old sample)? Maybe you are not updating the buffers fast enough (or not using two buffers)?

    Can you try to call nrf_drv_i2s_start(m_buffer_tx[0]) and then immediately nrf_drv_i2s_next_buffers_set(m_buffer_tx[1]) to prepare next buffer already? (This should however already be done by data_handler()) .Then in data_handler() you would alternate between m_buffer_tx[0] and [1] when calling nrf_drv_i2s_next_buffers_set(), just making sure you are not always using m_buffer_tx[1] and/or updating m_buffer_tx[1] when that is being played

    Kenneth

Related