例如设置sample_rate=48000,bits_per_sample=16,use_apll = true,fixed_mclk = 12288000;
static esp_err_t i2s_apll_calculate_fi2s计算得到真实:real rate: 47999.961
I (402) I2S: DMA Malloc info, datalen=blocksize=128, dma_buf_count=64
I (412) I2S: sdm0=2, sdm1=154, sdm2=4, odir=5
I (412) I2S: APLL: Req RATE: 48000, fi2s_rate: 12287990.000, real rate: 47999.961, BITS: 16, CLKM: 1, BCK_M: 8, MCLK: 12287990.000, SCLK: 1535998.750000, diva: 1, divb: 0
I (422) bsp_i2s_init: I2S driver installed.
如果i2s_apll_calculate_fi2s按照遍历方式寻找最佳的值得到更接近real rate: 47999.992,fi2s_rate也有一点点提高,不知道这样这几组值对结果有没有什么影响。
I (3162) I2S: sdm0=149, sdm1=212, sdm2=5, odir=6
E (3162) i2s_apll_get_fi2s: f_xtal:40000000,fout:393215936.000,fpll:12287998.000
I (3162) I2S: APLL: Req RATE: 48000, fi2s_rate: 12287998.000, real rate: 47999.992, BITS: 16, CLKM: 1, BCK_M: 8, MCLK: 12287998.000, SCLK: 1535999.750000, diva: 1, divb: 0
I (3182) bsp_i2s_init: I2S driver installed.
float f_xtal = (float)(rtc_clk_xtal_freq_get() * 1000000);
min_diff = APLL_MAX_FREQ;
float t_odir,t_sdm0,t_sdm1;
for (_odir = 0; _odir < 32; _odir ++){
t_odir = f_xtal / (2 * (_odir+2)) / 2;
for (_sdm0 = 0; _sdm0 < 256; _sdm0 ++) {
t_sdm0 = (_sdm0 / 65536.0f) + 4;
for (_sdm1 = 0; _sdm1 < 256; _sdm1 ++){
t_sdm1 = (_sdm1 / 256.0f) + t_sdm0;
for (_sdm2 = 4; _sdm2 < 9; _sdm2 ++)
{
//avg = i2s_apll_get_fi2s(bits_per_sample, _sdm0, *sdm1, *sdm2, *odir);
avg = t_odir * (t_sdm1 + _sdm2);
if (abs(avg - rate) < min_diff) {
min_diff = abs(avg - rate);
*odir = _odir;
*sdm0 = _sdm0;
*sdm1 = _sdm1;
*sdm2 = _sdm2;
}
}
}
}
}
i2s_apll_calculate_fi2s 计算问题
-
- Posts: 3
- Joined: Mon Nov 15, 2021 8:31 am
Jump to
- English Forum
- Explore
- News
- General Discussion
- FAQ
- Documentation
- Documentation
- Sample Code
- Discussion Forum
- Hardware
- ESP-IDF
- ESP-BOX
- ESP-ADF
- ESP-MDF
- ESP-WHO
- ESP-SkaiNet
- ESP32 Arduino
- IDEs for ESP-IDF
- ESP-AT
- ESP IoT Solution
- ESP RainMaker
- Rust
- ESP8266
- Report Bugs
- Showcase
- Chinese Forum 中文社区
- 活动区
- 乐鑫活动专区
- 讨论区
- 全国大学生物联网设计竞赛乐鑫答疑专区
- ESP-IDF 中文讨论版
- 《ESP32-C3 物联网工程开发实战》书籍讨论版
- 中文文档讨论版
- ESP-AT 中文讨论版
- ESP-BOX 中文讨论版
- ESP IoT Solution 中文讨论版
- ESP-ADF 中文讨论版
- ESP Mesh 中文讨论版
- ESP Cloud 中文讨论版
- ESP-WHO 中文讨论版
- ESP-SkaiNet 中文讨论版
- ESP 生产支持讨论版
- 硬件问题讨论
- 项目展示
Who is online
Users browsing this forum: No registered users and 11 guests
- All times are UTC
- Top
- Delete cookies
About Us
Espressif Systems is a fabless semiconductor company providing cutting-edge low power WiFi SoCs and wireless solutions for wireless communications and Internet of Things applications. ESP8266EX and ESP32 are some of our products.