HELP!ESP32-WROOM esp-idf4.4-dev 使能自动浅睡眠串口打印部分乱码
Posted: Wed Oct 20, 2021 9:27 am
问题描述:使能自动浅睡眠后,串口打印和接收均会时而出错时而正常,表现在乱码率高且串口解析数据错误率也极高。调用下面代码使能自动浅睡眠,屏蔽该函数串口正常。请问如何规避该问题,求指点迷津,谢谢您!
[img]C:\Users\LiKai\Desktop\printf.png[/img]
Code: Select all
void pm_auto_light_sleep_init(void)
{
#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_esp32_t pm_config = {
.max_freq_mhz = CONFIG_EXAMPLE_MAX_CPU_FREQ_MHZ, /* 最大CPU时钟频率 */
.min_freq_mhz = CONFIG_EXAMPLE_MIN_CPU_FREQ_MHZ, /* 没有频率锁定时使用的最小CPU频率 */
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
.light_sleep_enable = true /* 如果启用了无滴答空闲支持,则会启用自动浅睡眠 */
#endif
};
ESP_ERROR_CHECK( esp_pm_configure(&pm_config) );
deb_print(DBG_SOCK, "pm init\n");
#endif // CONFIG_PM_ENABLE
return;
}