Page 1 of 1

Uart2 does not work.

Posted: Fri Dec 16, 2016 2:20 pm
by readingmb
Hello !!
uart 2 does not work !!!
I am very urgent.
The code is written as follows:

Code: Select all

  uart_port_t uart_num = UART_NUM_2;                                     //uart port number
  uart_config_t uart_config = {
      .baud_rate = 115200,                    //baudrate
      .data_bits = UART_DATA_8_BITS,          //data bit mode
      .parity = UART_PARITY_DISABLE,          //parity mode
      .stop_bits = UART_STOP_BITS_1,          //stop bit mode
      .flow_ctrl = UART_HW_FLOWCTRL_DISABLE,  //hardware flow control(cts/rts)
      .rx_flow_ctrl_thresh = 122,             //flow control threshold
  };
  ESP_LOGI(TAG, "Setting UART configuration number %d...", uart_num);
  ESP_ERROR_CHECK( uart_param_config(uart_num, &uart_config));
  QueueHandle_t uart_queue;
  ESP_ERROR_CHECK( uart_set_pin(uart_num, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE));
  ESP_ERROR_CHECK( uart_driver_install(uart_num, 1024 * 2, 1024 * 2, 10, UART_INTR_NUM, &uart_queue));

  char* test_str = "This is a test string.\n";
  uart_tx_chars(uart_num, (const char*)test_str,strlen(test_str));
  printf("ESP32 uart Send\n");
  while(1);
The result screen is as follows.
However, it does not work.
I have measured it with an oscilloscope, but there is no signal.
I hope you solve it.

Code: Select all

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0x00
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3ffc0008,len:0
load:0x3ffc0008,len:1964
load:0x40078000,len:3668
load:0x40080000,len:260
entry 0x40080034
I (354) heap_alloc_caps: Initializing heap allocator:
I (355) heap_alloc_caps: Region 19: 3FFB4790 len 0002B870 tag 0
I (356) heap_alloc_caps: Region 25: 3FFE8000 len 00018000 tag 1
I (366) cpu_start: Pro cpu up.
I (372) cpu_start: Single core mode
I (378) cpu_start: Pro cpu start user code
I (402) rtc: rtc v160 Nov 22 2016 19:00:05
I (413) rtc: XTAL 40M
I (579) phy: phy_version: 258, Nov 29 2016, 15:51:07, 0, 0
I (971) cpu_start: Starting scheduler on PRO CPU.
I (973) SoftAP_Server: Setting UART configuration number 2...
I (973) UART: queue free spaces: 10
ESP32 uart Send

Re: Uart2 does not work.

Posted: Fri Dec 16, 2016 2:51 pm
by ESP_igrr
You need to specify some real pin number instead of UART_PIN_NO_CHANGE at least for the TXD pin. It will help if the pin you set is the same pin which you are probing with the scope.

Re: Uart2 does not work.

Posted: Sat Dec 17, 2016 6:51 am
by WiFive
ESP_igrr wrote:You need to specify some real pin number instead of UART_PIN_NO_CHANGE at least for the TXD pin. It will help if the pin you set is the same pin which you are probing with the scope.
:lol:

Maybe worth documenting with uart_set_pin function which UART have default pins and what they are?

Re: Uart2 does not work.

Posted: Sun May 12, 2019 10:46 am
by vinimac
Hello,

I have same issue, but I am not using default pins. In scope, there is no TX signal.

Code: Select all

#define RS485_TX            34
#define RS485_RX            22
#define RS485_DE            19

#define RS485UART           UART_NUM_2

uart_config_t uart_config = {
        .baud_rate = 9600,
        .data_bits = UART_DATA_8_BITS,
        .parity = UART_PARITY_DISABLE,
        .stop_bits = UART_STOP_BITS_1,
        .flow_ctrl = UART_HW_FLOWCTRL_DISABLE
    };
     // RS485 configuration
    uart_param_config(RS485UART, &uart_config);
    // RS485 pins
    uart_set_pin(RS485UART, RS485_TX, RS485_RX, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
    ESP_ERROR_CHECK(uart_driver_install(RS485UART, 128 * 2, 128 * 2, 0,
                                        NULL, 0));

Re: Uart2 does not work.

Posted: Sun May 12, 2019 1:15 pm
by WiFive
34 is input only, you can use for rx but not tx

Re: Uart2 does not work.

Posted: Sun May 12, 2019 8:07 pm
by vinimac
OMG, I cannot believe I missed this!

Thanks very much for the reply.