UART1 writes only "A"

glararan
Posts: 2
Joined: Sat Aug 05, 2017 11:59 am

UART1 writes only "A"

Postby glararan » Sun Aug 06, 2017 4:16 pm

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

Sinisa_PUF
Posts: 6
Joined: Thu Apr 20, 2017 3:15 pm
Location: Croatia
Contact:

Re: UART1 writes only "A"

Postby Sinisa_PUF » Wed Aug 09, 2017 2:01 pm

Hi. Try using UART_NUM_2. I could't get UART1 working in esp-idf nor Arduino but UART2 worked as expected.

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: UART1 writes only "A"

Postby Ritesh » Sun Aug 13, 2017 6:16 pm

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.
Regards,
Ritesh Prajapati

Who is online

Users browsing this forum: No registered users and 112 guests