完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
ESP32 C3, IDF 4.3.1版本, exampleswifipower_save这个例程,加上一个UART接收功能,发现UART数据接收不正常,收不到正确数据(但发UART数据可以)
测试程序如下: // check if power save/light sleep will affect uart or not static void uart_task(void *arg) { /* Configure parameters of an UART driver, * communication pins and install the driver */ uart_config_t uart_config = { .baud_rate = 115200, .data_bits = UART_DATA_8_BITS, .parity = UART_PARITY_DISABLE, .stop_bits = UART_STOP_BITS_1, .flow_ctrl = UART_HW_FLOWCTRL_DISABLE, .source_clk = UART_SCLK_APB, }; int intr_alloc_flags = 0; #if CONFIG_UART_ISR_IN_IRAM intr_alloc_flags = ESP_INTR_FLAG_IRAM; #endif ESP_ERROR_CHECK(uart_driver_install(ECHO_UART_PORT_NUM, BUF_SIZE * 4, 0, 0, NULL, intr_alloc_flags)); ESP_ERROR_CHECK(uart_param_config(ECHO_UART_PORT_NUM, &uart_config)); ESP_ERROR_CHECK(uart_set_pin(ECHO_UART_PORT_NUM, ECHO_TEST_TXD, ECHO_TEST_RXD, ECHO_TEST_RTS, ECHO_TEST_CTS)); // Configure a temporary buffer for the incoming data uint8_t *data = (uint8_t *) malloc(BUF_SIZE); while (1) { // Read data from the UART int len = uart_read_bytes(ECHO_UART_PORT_NUM, data, BUF_SIZE, 20 / portTICK_RATE_MS); if(len > 0) // // Write data back to the UART uart_write_bytes(ECHO_UART_PORT_NUM, (const char *) data, BUF_SIZE); vTaskDelay(20 / portTICK_PERIOD_MS); // every uart command gap 8ms data[0] = 0; } free(data); } void app_main(void) { // Initialize NVS esp_err_t ret = nvs_flash_init(); if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) { ESP_ERROR_CHECK(nvs_flash_erase()); ret = nvs_flash_init(); } ESP_ERROR_CHECK( ret ); #if CONFIG_PM_ENABLE // Configure dynamic frequency scaling: // maximum and minimum frequencies are set in sdkconfig, // automatic light sleep is enabled if tickless idle support is enabled. esp_pm_config_esp32c3_t pm_config = { .max_freq_mhz = CONFIG_EXAMPLE_MAX_CPU_FREQ_MHZ, .min_freq_mhz = CONFIG_EXAMPLE_MIN_CPU_FREQ_MHZ, #if CONFIG_FREERTOS_USE_TICKLESS_IDLE // note ,if enabled this (pw saving), uart will fail to work correctly .light_sleep_enable = true #endif }; ESP_ERROR_CHECK( esp_pm_configure(&pm_config) ); #endif // CONFIG_PM_ENABLE initialise_wifi(); xTaskCreate(uart_task, "uart_rev_task", ECHO_TASK_STACK_SIZE, NULL, 10, NULL); // configMAX_PRIORITIES - 0 wifi_power_save(); } 当在menuconfig中disable power saving后,串口才能接收正常。 请问,是否是在light sleep 模式下, C3的串口接收不能正常工作? |
|
相关推荐
1个回答
|
|
同遇到这个问题,楼主后面有解决或者找到相关资料吗
|
|
|
|
只有小组成员才能发言,加入小组>>
350 浏览 0 评论
1196 浏览 1 评论
588浏览 6评论
484浏览 5评论
有没有办法在不使用混杂模式的情况下实现Wifi驱动程序接收缓冲区访问中断呢?
468浏览 5评论
467浏览 4评论
443浏览 4评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-29 10:45 , Processed in 0.917398 second(s), Total 78, Slave 62 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号