AliOS-Things
AliOS-Things copied to clipboard
ESP32无法使用串口1,2
ESP32串口0(下载&log)可以正常使用。配置串口1和2时,无法发送数据。
// 初始化
uart_dev_t uart_1;
uart_1.port = 1;
uart_1.config.baud_rate = 115200;
uart_1.config.data_width = DATA_WIDTH_8BIT;
uart_1.config.parity = NO_PARITY;
uart_1.config.stop_bits = STOP_BITS_1;
uart_1.config.flow_control = FLOW_CONTROL_DISABLED;
hal_uart_init(&uart_1);
// 循环发送测试命令 但SD3管脚(UART1_Tx)并未有数据输出。
hal_uart_send(&uart_1,"test", 4, 500);
找到原因,在调用hal_uart_init之前要先调用uart_param_config和uart_set_pin配置参数和管脚。
@leoadvance 你好,我刚开始弄esp32.请问有没有esp32对串口操作的例程。我参考下。看aliosthings,不知道从哪里下嘴,谢谢