1
完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
您好,我正在尝试在 IDF 5.0 引入的连续模式中使用 ADC,但是我在 adc_continuous_config_t 中指定的采样率与我实际得到的不相关。这是我正在运行的代码:
代码:全选 #include #include "esp_timer.h" #include "freertos/FreeRTOS.h" #include #include #include #define SAMPLE_RATE 40000 adc_continuous_handle_t adcHandle = NULL; std::atomic_uint32_t sampleCount; void printSampleRateTask(void *arg) { uint32_t samplesPerSecond = sampleCount.exchange(0, std::memory_order_acq_rel); printf("Time: %lld, samples per second: %lu\n", esp_timer_get_time(), samplesPerSecond); } extern "C" void app_main() { adc_continuous_handle_cfg_t handle_cfg = { .max_store_buf_size = 2000, .conv_frame_size = 1000, }; ESP_ERROR_CHECK(adc_continuous_new_handle(&handle_cfg, &adcHandle)); adc_digi_pattern_config_t channel[1] = {}; channel[0].atten = ADC_ATTEN_DB_11; channel[0].channel = 0; channel[0].unit = 0; channel[0].bit_width = SOC_ADC_DIGI_MIN_BITWIDTH; adc_continuous_config_t cfg = { .pattern_num = 1, .adc_pattern = channel, .sample_freq_hz = SAMPLE_RATE, .conv_mode = ADC_CONV_SINGLE_UNIT_1, .format = ADC_DIGI_OUTPUT_FORMAT_TYPE1, }; ESP_ERROR_CHECK(adc_continuous_config(adcHandle, &cfg)); ESP_ERROR_CHECK(adc_continuous_start(adcHandle)); const esp_timer_create_args_t periodic_timer_args = { .callback = &printSampleRateTask, .name = "sampleRate", }; esp_timer_handle_t periodic_timer; ESP_ERROR_CHECK(esp_timer_create(&periodic_timer_args, &periodic_timer)); ESP_ERROR_CHECK(esp_timer_start_periodic(periodic_timer, 1000000)); esp_err_t ret; uint32_t ret_num = 0; uint8_t result[1000] = {0}; while (1) { ret = adc_continuous_read(adcHandle, result, sizeof(result), &ret_num, 1000); if (ret == ESP_OK) { sampleCount += ret_num / SOC_ADC_DIGI_RESULT_BYTES; } else { printf("status: %d\n", ret); } } } 这是串行输出的摘录: 代码:全选 Time: 1028996, samples per second: 32500 Time: 2028961, samples per second: 32500 Time: 3028961, samples per second: 33000 Time: 4028961, samples per second: 32500 Time: 5028961, samples per second: 33000 Time: 6028961, samples per second: 32500 Time: 7028961, samples per second: 33000 Time: 8028961, samples per second: 32500 Time: 9028961, samples per second: 32500 Time: 10028961, samples per second: 33000 Time: 11028961, samples per second: 32500 Time: 12028961, samples per second: 33000 Time: 13028961, samples per second: 32500 这就是 IDF 在构建时所说的: 代码:全选 CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/wemos_d1_mini32.html PLATFORM: Espressif 32 (5.3.0+sha.98b1e96) > WEMOS D1 MINI ESP32 HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa) PACKAGES: - framework-espidf @ 3.50000.0 (5.0.0) - tool-cmake @ 3.16.4 - tool-esptoolpy @ 1.40400.0 (4.4.0) - tool-mkfatfs @ 2.0.1 - tool-mklittlefs @ 1.203.210628 (2.3) - tool-mkspiffs @ 2.230.0 (2.30) - tool-ninja @ 1.7.1 - toolchain-esp32ulp @ 1.23500.220830 (2.35.0) - toolchain-xtensa-esp32 @ 11.2.0+2022r1 我试过更改采样率、缓冲区大小以及 max_store_buf_size 和 conv_frame_size,但没有任何组合可以使采样率匹配。我怎样才能让它更精确? |
|
相关推荐 |
|
只有小组成员才能发言,加入小组>>
1932个成员聚集在这个小组
加入小组我的项目我做主,使用GN+Ninja来完成构建系统(VSCode开发RT106X)
36419 浏览 0 评论
NXP IMX8应用处理器快速入门必备:技巧、使用、设计指南
4841 浏览 1 评论
6105 浏览 1 评论
6815 浏览 0 评论
NXP i.MX6UL开发板(linux系统烧录+规格+硬件+模块移植)使用手册
4247 浏览 0 评论
642浏览 2评论
求助,S32G上Core M启动后如何让Core A在Flash指定位置加载uboot?
639浏览 2评论
ESP32-WROVER-IE + LAN8720以太网,GPIO0电压只有1.6v,无法正常进入spi flash boot模式如何解决?
640浏览 2评论
求分享适用于PN7160 Android的NFC工厂测试应用程序
727浏览 2评论
841浏览 2评论
小黑屋| 手机版| Archiver| 德赢Vwin官网 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-21 23:09 , Processed in 1.024522 second(s), Total 75, Slave 59 queries .
Powered by 德赢Vwin官网 网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
德赢Vwin官网 观察
版权所有 © 湖南华秋数字科技有限公司
德赢Vwin官网 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号