Open VK2BEA opened 2 years ago
Is anything happening on this problem?
Is the issue exists on other released branch? I didn't catch any clue where the glitches might come from 😟
It seems not a software issue,I monitored the clock of APLL, it looks pretty well, and it's totally same with the PLL clock. I used two DMA strategies to transport the data, not work, it's not likely a DMA problem as well.
The most possible reason I guess is these two clock domain (APLL for I2S DMA and RTC for DAC) are affected by each other. Due to the APLL generated a good clock, I doubt RTC is interfered by something that introduced by the APLL
It happens on all the branches / releases I've tried and on several hardware platforms.
I tried again with the data that calculated by sin
and found the glitches are gone
uint8_t w_buf[800] = {0};
for (int i = 0; i < 800; i+=2) {
uint8_t val = (uint8_t)((sin(2 * 3.1416 * ((float)i / 800.0)) + 1) * 127);
w_buf[i + 1] = val;
}
No this does not fix the problem. What you have done is to create two in phase sine waves. It does seem that the problem is LESS visible when the data from both DACs is the same but the problem IS still there. My example has two sine waves in quadrature (90 degrees out of phase). The problem is more evident / reproducible there.
Yeah, you're right! Seems the phase shift between the two channels will indeed bring more glitches.
I tested the case on the new driver-NG of DAC (not merged yet), the glitches are still there, but they don't show up on ESP32-S2 under same conditions.
And I checked the sent data as well, at least the data is correct after they are transmitted by DMA, the only possible point that breaks the data should between DMA and DAC converter. Which might be a hardware bug, sadly I'm not sure if there will be a solution for this issue. I'll report the issue to the hardware designer.
Thanks, I was concerned that it may be hardware related. Do you know if it is also OK on the S3 (I need the dual core)? -- edit ... never mind, I see the S3 doesn't have a DAC 8-( Does this mean that the on-board DAC is broken and cannot be used reliably? Are there settings where it doesn't glitch (i.e. can I find a work-around)?
I haven't received any comments from hardware team yet, seems it's an unknown bug, probably no work-around for this. If you only need to generated a sine wave from DAC module, is it possible to use the DAC cosine wave generator?
You can have a try using the patch of the DAC driver-ng preview (based on master)
You can check the dac examples in the patch to learn how to use it.
Alas, no I cannot use the cosine generator. I'm generating low frequency tones of very precise frequencies .. https://en.wikipedia.org/wiki/Continuous_Tone-Coded_Squelch_System#List_of_tones The cosine generator does not have the resolution needed to generate the exact frequencies.
Sounds like DAC DMA is the only solution, may I ask how low the frequency might be? According to my test, PLL can support down to 20KHz converting rate on ESP32, if it's not low enough, the one work-around could be duplicating the data meanwhile double the converting rate.
the lowest is 67 Hz the highest 254 Hz.
the lowest is 67 Hz the highest 254 Hz.
Is this a sine wave frequency or DAC conversion rate of each data?
gptimer
to generate the interrupt at your specific frequency.As far as I know, I am afraid the only possibility is to use an older version of idf.
I am using Arduino as IDE. With the latest version if .use_apll = 1 the glitches appear. In this version of IDF .use_apll = false, no glitches appear. However with an older version of IDF and .use_apll = 1 these glitches do not appear.
Additional information if you are not familiar with ESP32 and IDE Aduino
When in Preferences del Arduino IDE you write (This is declared as the latest estable release) https://dl.espressif.com/dl/package_esp32_index.json Then in the Board Manager ESP32 you can load the Board Manager 1.0.6 and later choose your board Then with .use_apll = 1 these glitches do not appear.
In case you need new ESP boards (i.e. ESP32 Adafruit feather V2) then you need to include in preferences Arduino IDE https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json (information you can get i.e. in Adafruit WEB) After that you can use the Board Manager up 2.0.5 in the Arduino IDE Advantage: you can choose as board the Adafruit ESP32 feather V2 Disadvantage: if .use_apll = 1 the glitches appear
To be change in the Sketch
with Board Manager 1.0.6
//Configuration for the I2S bus
.communication_format = I2S_COMM_FORMAT_I2S_MSB,
with Board Manager 2.0.5 //Configuration for the I2S bus .communication_format = I2S_COMM_FORMAT_STAND_MSB,
Good Luck!
As far as I know, I am afraid the only possibility is to use an older version of idf.
I am using Arduino as IDE. With the latest version if .use_apll = 1 the glitches appear. In this version of IDF .use_apll = false, no glitches appear. However with an older version of IDF and .use_apll = 1 these glitches do not appear.
How old ? (what version works?) This is good news and means that it is not a hardware issue. I'm not using Arduino but straight C (as demonstrated in the example above)
Michael
Dear Michael,
"How old ? (what version works?)" I cannot give you a precise answer.
I have been working the last two years with the so call IDF stable version (in Preferences) and the Board Manager 1.0.6 (captures attached) Board Adafruit Feather ESP32
Only when about two months ago I realized about the Board Adafruit Feather ESP32 V2 I bought this board for evaluation then I had to upgrade to the Development release and Board Manager 2.0.5
with this upgrade the behavior of my old Board Adafruit Feather ESP32 is not the same when using DMA DAC.
Good luck!
https://dl.espressif.com/dl/package_esp32_index.json
https://learn.adafruit.com/adafruit-esp32-feather-v2/arduino-ide-setup
De: Michael G. Katzmann @.*** Enviado el: sábado, 08 de octubre de 2022 4:12 Para: espressif/esp-idf CC: JoseEnriqueFA; Comment Asunto: Re: [espressif/esp-idf] Internal DAC glitches using I2S ".use_apll = true" (IDFGH-7784) (Issue #9321)
As far as I know, I am afraid the only possibility is to use an older version of idf.
I am using Arduino as IDE. With the latest version if .use_apll = 1 the glitches appear. In this version of IDF .use_apll = false, no glitches appear. However with an older version of IDF and .use_apll = 1 these glitches do not appear.
How old ? (what version works?) This is good news and means that it is not a hardware issue. I'm not using Arduino but straight C (as demonstrated in the example above)
Michael
— Reply to this email directly, view it on GitHub https://github.com/espressif/esp-idf/issues/9321#issuecomment-1272197615 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AML3OVAEM7QSTLBKEDCFQJTWCDJ6VANCNFSM53DUPZDA . You are receiving this because you commented. https://github.com/notifications/beacon/AML3OVCETNKRONNFYIASRKDWCDJ6VA5CNFSM53DUPZDKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOJPKDD3Y.gif Message ID: @.***>
I have found this URL https://github.com/espressif/arduino-esp32/releases?page=1 ** where you can read "[ESP32 Arduino Release 1.0.6 based on ESP-IDF v3.3.5] (https://github.com/espressif/arduino-esp32/releases/tag/1.0.6)"
When I use the "Release 1.0.6" in Arduino IDE I can use_"apll = 1" glitches free
Best whishes José
**PD : Only FYI, I was looking for information in the WEB. In the latest version ESP32 Arduino 2.0.5 based on ESP-IDF 4.4.2 I have identified two problems, I am investigating ...
HI,
I have found this URL https://github.com/espressif/arduino-esp32/releases?page=1 **
where you can read " https://github.com/espressif/arduino-esp32/releases/tag/1.0.6 ESP32 Arduino Release 1.0.6 based on ESP-IDF v3.3.5"
When I use the "Release 1.0.6" in Arduino IDE I can use_"apll = 1" glitches free
Best whishes
José
**PD : Only FYI, I was looking for information in the WEB.
In the latest version ESP32 Arduino 2.0.5 based on ESP-IDF 4.4.2
I have identified two problems, I am investigating ...
De: Michael G. Katzmann @.*** Enviado el: sábado, 08 de octubre de 2022 4:12 Para: espressif/esp-idf CC: JoseEnriqueFA; Comment Asunto: Re: [espressif/esp-idf] Internal DAC glitches using I2S ".use_apll = true" (IDFGH-7784) (Issue #9321)
As far as I know, I am afraid the only possibility is to use an older version of idf.
I am using Arduino as IDE. With the latest version if .use_apll = 1 the glitches appear. In this version of IDF .use_apll = false, no glitches appear. However with an older version of IDF and .use_apll = 1 these glitches do not appear.
How old ? (what version works?) This is good news and means that it is not a hardware issue. I'm not using Arduino but straight C (as demonstrated in the example above)
Michael
— Reply to this email directly, view it on GitHub https://github.com/espressif/esp-idf/issues/9321#issuecomment-1272197615 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AML3OVAEM7QSTLBKEDCFQJTWCDJ6VANCNFSM53DUPZDA . You are receiving this because you commented. https://github.com/notifications/beacon/AML3OVCETNKRONNFYIASRKDWCDJ6VA5CNFSM53DUPZDKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOJPKDD3Y.gif Message ID: @.***>
I am having a similar issue, where the I2S/DAC is now generating very noisy audio. I use the I2S to feed 8bit 22050Hz data to the DAC. On IDF version 4.2.2 this worked fine, but in 4.4.3 the sound quality is very bad. This would seem to indicate it is not a hardware issue, or if it is, some configuration in the IDF must have made it worse. Has any progress been made to identify the problem and come up with some work-arounds?
When it has changed in a certain IDF version, you need to check that all parameters are being initialised correctly:
As an example of code that works, have a look at https://raw.githubusercontent.com/earlephilhower/ESP8266Audio/master/src/AudioOutputI2S.cpp more specifically, following lines of code are relevant
if (output_mode == INTERNAL_DAC)
{
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 2, 0)
comm_fmt = (i2s_comm_format_t) I2S_COMM_FORMAT_STAND_MSB;
#else
comm_fmt = (i2s_comm_format_t) I2S_COMM_FORMAT_I2S_MSB;
#endif
}
....
i2s_config_t i2s_config_dac = {
.mode = mode,
.sample_rate = 44100,
.bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT,
.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
.communication_format = comm_fmt,
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1, // lowest interrupt priority
.dma_buf_count = dma_buf_count,
.dma_buf_len = 128,
.use_apll = use_apll, // Use audio PLL
.tx_desc_auto_clear = true, // Silence on underflow
.fixed_mclk = use_mclk, // Unused
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 4, 0)
.mclk_multiple = I2S_MCLK_MULTIPLE_256, // Unused
.bits_per_chan = I2S_BITS_PER_CHAN_DEFAULT // Use bits per sample
#endif
};
Environment
Problem Description
The output of the DAC is glitchy when the "use_apll" is set TRUE. It is very clean when the PLL is off (use_apll set to off). For my application I must use the PLL. Without the PLL, the correct sampling frequency cannot be generated.
See the attached pictures. The glitches are random (non synchronous to the waveform and vary).
In the sample code I am generating two quadrature sinewaves at 100 Hz.
Expected Behavior
Clean signals generated at the DAC outputs corresponding to the digital values set
Actual Behavior
Random noise on DAC outputs
Steps to reproduce
Code to reproduce this issue
Here is a trace showing the glitches are random (non-periodic) Here is a trace showing a close up of the glitches
again, the gliches to not occur if the clock is not using the PLL (indicating the code is good)
Michael