I’m having some issues with the DAC output when driving it using I2S DMA. Wondering if this is a known issue or if anyone has encountered it before and solved it.
When driving the DAC using I2S DMA, there seems to be some bit error on even/odd LSBs. See picture below.
Driving it by repeatedly calling dac_output_voltage with the same waveform data produces a correct output though.
Note: Using Stable 5.0.2 release. Have tried various frequencies and options.
I2S driven DMA DAC
-
- Posts: 9739
- Joined: Thu Nov 26, 2015 4:08 am
Re: I2S driven DMA DAC
You're probably feeding the data in the wrong way. The DAC takes 16-bit samples packed in 32-bit words, but in mono mode, it'll take the upper 16-bit of a word first, then the lower 16-bit word. The ESP32 is little-endian, though, so you'll need to do some flipping. Pseudo-code to get what you probably want:
Code: Select all
uint16_t buf_to_send[256];
for (int x=0; x<256; x++) {
//this fills elements in sequence 1,0,3,2,5,4,...
buf_to_send[x^1]=x;
}
i2s_send(buf_to_send);
Who is online
Users browsing this forum: Baidu [Spider] and 85 guests