-
Notifications
You must be signed in to change notification settings - Fork 7.3k
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
Faulty clock output in I2S PDM TX DAC mode on ESP32-S3 (IDFGH-9010) #10420
Comments
Hi @thebender7 , many thanks for your bug report!
To sum up, PDM TX can only support up to |
Hi @L-KAYA thank's a lot for your answer! i wonder what are the correct settings in order to get an oversampling of 64? I tried different values for fp = fs but even for sampling rates < 48kHz i was not able to get a clock. Many thanks for your help! |
Hi @thebender7 ,
Thank you for your question, please let me know if there are still something not clear. |
Hi @L-KAYA, thank you for the clarifications! I tried to set the osr2 = 1 directly as you suggested (while keeping fp = 960, fs = 480), however the setting has no effect on the sample rate e.g. the oversampling is still 128. From my experience so far, as long as fp/fs = 2 the sample rate is not connected to fs but is sample_rate = bckl / 128. Sorry for not mentioning this before but not only the clock output is faulty but also the data output shows the same corruption. Thank you! |
May I ask what's your expected clock frequency and data wave? |
Hi @L-KAYA , our application uses ultrasonic, sine shaped pulses in the frequency range 20 - 70 kHz. We therefore aim at a sample rate of 156250 Hz. For an oversampling ratio of 128 however due to the limitation that bckl_div >= 8 the maximum possible sample rate is 156250 / 2 for bckl_div = 8. The bckl_freq is than 160MHz/2/8 = 10 MHz and sample rate = 10 MHz / 128. If for these clock settings the oversampling could be reduced to 64 than we would end up at the required sample rate. The initialization code is taken from the I2S_PDM_TX example of IDE 5.0 but slightly adapted in order to get a 2 line dac signal on two seperate gpios:
|
I see, so you want to generate a 20 - 70 kHz sine wave by PDM right? According to my test, it's not possible to reach 70kHz, the maximum frequency of the sine wave is near 30kHz. If you only need to generate a sine wave likewise, there are several other ways you can have a try:
|
Hello Team,
i am having troubles operating the I2S0 in PDM TX DAC Stereo Mode at high sample rates (>75kHz) on a ESP32-S3.
First there is a little bug in the driver file i2s_pdm.c (ln 38):
clk_info->bclk = rate * I2S_LL_PDM_BCK_FACTOR * pdm_tx_clk->up_sample_fp / pdm_tx_clk->up_sample_fs;
this expression leads to an overflow for large sampling rates as bckl is only 32bit. This can be easily overcome by adding brackets:
clk_info->bclk = rate * I2S_LL_PDM_BCK_FACTOR * (pdm_tx_clk->up_sample_fp / pdm_tx_clk->up_sample_fs);
Furthermore for achieving high sample rates also the default value for the bitclock divider needs to be reduced(ln 39):
clk_info->bclk_div = 4;
Target sample rate is 156250 Hz which should be met with a mclk divider of 2.
When doing so however i get a faulty clock manifesting in interruptions of the clock at the period of the sample rate such that the last 10% of the sample time the clock signal drops to zero and begins again with the next sample.
It seems that for bckl_div < 8 the bit clock is not working properly. In the technical reference manual i could not find any restrictions for bclk_div for PDM TX applications. Is this expected behaviour?
Another way of reaching 156250 Hz while keeping bclk_div = 8 seems to set the oversampling ratio to 64 e.g. OSR2 = 1.
When doing so by setting in i2s_pdm.h f_p = f_s such that OSR2 = f_p / f_s =1 i get no clock output at all, only glitches at the rate of the sample rate. From documentation the actual meaning of f_p and f_s and their connection to the sample rate stay quite unclear to me. Is an OSR2 of 1 not forseen or am i missing something?
Thank you everybody for any hints to understand the behaviour.
Best,
Helmar
The text was updated successfully, but these errors were encountered: