Page 1 of 1

UART1 writes only "A"

Posted: Sun Aug 06, 2017 4:16 pm
by glararan
Hi,

I have ESP32 from WeMos. Using uart0 for DEBUG thourgh USB. I configured uart1 to GPIO4(RX), GPIO2(tx). Plugged uart1 to USB serial converter.

Both uarts running at 115200bps. Uart1 should work as communication betweern AI Thinker A7 (GSM module). I'm basicly trying to write "AT\r". What I can see is only "AA...". I also tested GSM module it works (with USB-serial) (in this point, GSM module is not attached!). uart1 is attached to USB-Serial.

If I change in my program

Code: Select all

uart_write_bytes(UART_NUM_1, (const char*)buffer, len);
to

Code: Select all

uart_write_bytes(UART_NUM_0, (const char*)buffer, len);
I can see correct output. There must be definitely some problem with uart1.

Serial monitors: Arduino IDE

Configuration:

Code: Select all

#define UART_BUFF_SIZE 256

#define UART_2_TXD GPIO_NUM_2
#define UART_2_RXD GPIO_NUM_4

extern "C" void app_main()
{
	// Flash
	nvs_flash_init();

	// log
	esp_log_level_set("*", ESP_LOG_NONE);

	// UART
	uart_config_t serialConfig =
	{
		.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,
		.rx_flow_ctrl_thresh = UART_HW_FLOWCTRL_CTS_RTS
	};

	uart_set_pin(UART_NUM_0, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
	uart_param_config(UART_NUM_0, &serialConfig);
    uart_driver_install(UART_NUM_0, UART_BUFF_SIZE * 2, UART_BUFF_SIZE * 2, 0, NULL, 0);
	uart_flush(UART_NUM_0);

	// UART 2
	uart_config_t serialConfig2 =
	{
		.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,
		.rx_flow_ctrl_thresh = UART_HW_FLOWCTRL_CTS_RTS
	};

    uart_set_pin(UART_NUM_1, UART_2_TXD, UART_2_RXD, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
	uart_param_config(UART_NUM_1, &serialConfig2);
    uart_driver_install(UART_NUM_1, UART_BUFF_SIZE * 2, UART_BUFF_SIZE * 2, 0, NULL, 0);
	uart_flush(UART_NUM_1);

    // Tasks
    xTaskCreate(&mainTask, "mainTask", 4096, NULL, 7, NULL);
}
Any idea what's my problem? Thanks

Re: UART1 writes only "A"

Posted: Wed Aug 09, 2017 2:01 pm
by Sinisa_PUF
Hi. Try using UART_NUM_2. I could't get UART1 working in esp-idf nor Arduino but UART2 worked as expected.

Re: UART1 writes only "A"

Posted: Sun Aug 13, 2017 6:16 pm
by Ritesh
glararan wrote:Hi,

I have ESP32 from WeMos. Using uart0 for DEBUG thourgh USB. I configured uart1 to GPIO4(RX), GPIO2(tx). Plugged uart1 to USB serial converter.

Both uarts running at 115200bps. Uart1 should work as communication betweern AI Thinker A7 (GSM module). I'm basicly trying to write "AT\r". What I can see is only "AA...". I also tested GSM module it works (with USB-serial) (in this point, GSM module is not attached!). uart1 is attached to USB-Serial.

If I change in my program

Code: Select all

uart_write_bytes(UART_NUM_1, (const char*)buffer, len);
to

Code: Select all

uart_write_bytes(UART_NUM_0, (const char*)buffer, len);
I can see correct output. There must be definitely some problem with uart1.

Serial monitors: Arduino IDE

Configuration:

Code: Select all

#define UART_BUFF_SIZE 256

#define UART_2_TXD GPIO_NUM_2
#define UART_2_RXD GPIO_NUM_4

extern "C" void app_main()
{
	// Flash
	nvs_flash_init();

	// log
	esp_log_level_set("*", ESP_LOG_NONE);

	// UART
	uart_config_t serialConfig =
	{
		.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,
		.rx_flow_ctrl_thresh = UART_HW_FLOWCTRL_CTS_RTS
	};

	uart_set_pin(UART_NUM_0, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
	uart_param_config(UART_NUM_0, &serialConfig);
    uart_driver_install(UART_NUM_0, UART_BUFF_SIZE * 2, UART_BUFF_SIZE * 2, 0, NULL, 0);
	uart_flush(UART_NUM_0);

	// UART 2
	uart_config_t serialConfig2 =
	{
		.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,
		.rx_flow_ctrl_thresh = UART_HW_FLOWCTRL_CTS_RTS
	};

    uart_set_pin(UART_NUM_1, UART_2_TXD, UART_2_RXD, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
	uart_param_config(UART_NUM_1, &serialConfig2);
    uart_driver_install(UART_NUM_1, UART_BUFF_SIZE * 2, UART_BUFF_SIZE * 2, 0, NULL, 0);
	uart_flush(UART_NUM_1);

    // Tasks
    xTaskCreate(&mainTask, "mainTask", 4096, NULL, 7, NULL);
}
Any idea what's my problem? Thanks
Hi,

Would.you please share whole.code include task code which you have created at the end?

Because, we have successfully configured both UART1 and UART2 in our application and it works fine without any issue.