【求助】win连接串口会导致开发板按键失效

lir419
Posts: 2
Joined: Tue Jun 15, 2021 9:06 am

【求助】win连接串口会导致开发板按键失效

Postby lir419 » Tue Jun 15, 2021 9:16 am

问题描述:
使用idf.py monitor,不论什么操作系统,功能都正常;
使用macOS screen命令,功能正常;
使用Windows putty或xshell,会有这种异常情况:串口open的那一刻会导致板子reboot,可以正常看到板子的串口打印信息,板子的按键失灵,无法触发 gpio_isr_handler -> xQueue 事件

请问是什么原因导致按键失效呢?

设备描述:
使用开发板:ESP32-C3
配置GPIO9(boot键),并如下代码来初始化按键:
  1.     gpio_config_t io_conf;
  2.  
  3.     io_conf.intr_type = GPIO_INTR_ANYEDGE;
  4.     io_conf.pin_bit_mask = GPIO_BTN_PIN_SEL;
  5.     //set as input mode
  6.     io_conf.mode = GPIO_MODE_INPUT;
  7.     io_conf.pull_up_en = GPIO_PULLUP_ENABLE;
  8.     ret = gpio_config(&io_conf);
  9.     if (ret) {
  10.         ESP_LOGE(TAG, "gpio config failed: %s\n", esp_err_to_name(ret));
  11.         return;
  12.     }
  13.  
  14.     //create a queue to handle gpio event from isr
  15.     btn_evt_queue = xQueueCreate(10, sizeof(uint8_t));
  16.     //start gpio task
  17.     xTaskCreate(btn_task, "btn_task", 2048, NULL, 10, NULL);
  18.  
  19.     //install gpio isr service
  20.     ret = gpio_install_isr_service(ESP_INTR_FLAG_DEFAULT);
  21.     if (ret) {
  22.         ESP_LOGE(TAG, "gpio install isr failed: %s\n", esp_err_to_name(ret));
  23.         return;
  24.     }
  25.     //hook isr handler for specific gpio pin
  26.     ret = gpio_isr_handler_add(GPIO_BTN_IO, gpio_isr_handler, (void*) GPIO_BTN_IO);
  27.     if (ret) {
  28.         ESP_LOGE(TAG, "gpio isr add failed: %s\n", esp_err_to_name(ret));
  29.         return;
  30.     }

lir419
Posts: 2
Joined: Tue Jun 15, 2021 9:06 am

Re: 【求助】win连接串口会导致开发板按键失效

Postby lir419 » Tue Jun 15, 2021 10:25 am

通过windows中的linux虚拟机来连接,也会有按键失效的问题。

用golang写了一个自己的纯净串口程序,也会导致按键失效。

如果只是连接windows,而不打开串口,则没事,按键正常。

ESP_Gargamel
Posts: 786
Joined: Wed Nov 14, 2018 8:45 am

Re: 【求助】win连接串口会导致开发板按键失效

Postby ESP_Gargamel » Thu Jun 17, 2021 2:40 am

GPIO9 在 Auto Program 电路上,受 RTS & DTR 控制,建议使用可以设置 RTS & DTR 的串口终端,比如 ComTool:https://github.com/Neutree/COMTool/releases,勾选上 RTS & DTR,然后再试一下。

Who is online

Users browsing this forum: No registered users and 54 guests