-
Notifications
You must be signed in to change notification settings - Fork 7.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PDM microphone input corrupted when DFS is enabled while using APLL (IDFGH-13860) #14707
Comments
@L-KAYA Reading through this commit, as far as I can tell this completely removes the ability to use DFS frequencies below APB_MAX with a number of different peripherals and modes (DAC DMA, I2S PDM, I2S STD, I2S TDM, and I2S LCD). I can't speak to all of these modes. That said, we currently use DFS to switch between 10MHz run and 80MHz run with I2S STD mode. This is already deployed on a production device, and it works well. The reported issue is only with I2S PDM mode. I suspect there are other teams which would have similar issues, since this is a breaking change that removes functionality. Additionally, as noted in the original report, this issue occurs whenever the CPU frequency changes. Holding the ESP_PM_APB_FREQ_MAX is not sufficient to prevent this issue when I2S PDM mode is used, because e.g. switching from 80MHz run to 240MHz run also causes the issue. |
Hi @therealergo, thanks for your feedback! I'm sorry that the fix doesn't solve the issue, and seems I misunderstood your problem. Let me confirm again, and please correct me if I have something wrong:
If the audio speed and the clock are both correct but only the audio corrupted when CPU frequency changed, it might probably an issue in the PDM2PCM converter. Anyway, I'll have a further investigation and will post here if there are any new questions or findings. Sorry again for the inconvenience, please feel free to re-open the issue~ |
@L-KAYA Thanks for looking into it! To answer each of these:
Based on the situations that I've seen fail, my assumption is roughly the same. It's either an issue with interrupt handling, or an issue with the PDM2PCM converter itself. Please do let me know what you find on further investigation! Please do re-open the issue. |
Hi @therealergo I have reproduced the issue on my side! Conclusions
Generally, it probably a hardware issue (just a speculation with no evidence, maybe some i2s registers react too slow to latch the correct data when APB is at low frequency). It is not likely to be fixed directly, but can be bypassed by holding the APB frequency (which has been fixed in the commit). Test ResultsDFS offDFS on (APLL)min_freq = 10MHzmin_freq = 20MHz(No idea why 20MHz get such a bad performance 😂 ) min_freq = 40MHz(Seem to be the best when APB and CPU lower than 80MHz) min_freq = 80MHzmin_freq = 10MHz + APB freq lockDFS on (PLL) |
Hi @therealergo, I did some further tests for the STD mode (with ESP32-LyraT board, which carries es8388 codec). Here is the waveform (16 KHz, 16-bit): Although they look pretty same, and seem no glitches in the audio, it sounds different actually. The music sounds like bouncing and contains short-period echo. After some discussion, it is confirmed that it's a timing issue that caused by the cross-clock-domain data transmission. The DMA and I2S module are in different clock domains, when the DFS is on, the I2S module stay fixed as it is clocked by APLL, but DMA source clock is dynamic, which makes it lost synchronization, and the data/bit sequence might go wrong. Such disorder won't affect too much to the STD mode, because it is PCM format data already, switching some data can only make the audio sounds weird. But the will increase the noise to the PDM mode, because the PDM2PCM converter filters the raw PDM data based on a correct sequence, otherwise there will be glitches and noise. This cross-clock-domain issue should only exist on ESP32 and ESP32-S2, so ESP32-P4 can still use APLL + DFS with APB frequency scalable. This issue will be closed, since now we have to acquire the APB lock to ensure the DMA clock domain won't be dynamic when using APLL + DFS feature. |
Hi @L-KAYA, thanks for looking into this further. To be sure, it sounds like a silicon issue in the ESP32 prevents this feature from functioning as intended, correct? That is unfortunate, since it was a documented feature that worked well enough that we have already deployed a significant number of devices which use it. After doing extensive testing and optimization on our end, we can work around it with a 20-40% battery life penalty in our application. Is it possible for you to better quantify what "switching some data" means in the I2S STD case? None of our testing found any "echo" or "bouncing" in the I2S STD audio, but we may have seen one case where the two I2S channels seemed to randomly swap. Could this bug cause that? With this change in place, there is other documentation that needs to be changed to remove references to this feature. For example, the pictured "Power Management" section of the programming guide also needs to be updated: After re-testing on my end, I see why I didn't think that it was related to APB frequency. I assumed that setting the CPU minimum frequency to 80MHz would make the APB always remain at 80MHz too, since the APB_CLK is derived from CPU_CLK. However, digging through Interestingly, if I remove the check in |
Answers checklist.
IDF version.
v5.3.1
Espressif SoC revision.
ESP32
Operating System used.
Windows
How did you build your project?
Command line with idf.py
If you are using Windows, please specify command line type.
PowerShell
Development Kit.
Custom Board
Power Supply used.
USB
What is the expected behavior?
Clear audio to be recorded from a pair of PDM microphones.
What is the actual behavior?
Audio contains random crackles and pops.
Steps to reproduce.
Debug Logs.
No response
More Information.
As far as I can tell from the ESP-IDF documentation, datasheet, and reference manual, this configuration should be fully supported. The documentation claims that the I2S peripheral should be able to run from the APLL while only holding the NO_LIGHT_SLEEP power management lock, and the datasheet and reference manual do not suggest that changing the CPU or APB bus speed in this configuration will cause any issues.
The text was updated successfully, but these errors were encountered: