Page 1 of 1

Spurios UART1 reading

Posted: Tue Apr 24, 2018 10:18 am
by davdav
Hi everybody,
In our project the ESP32 can be connected throught its UART1 port (only TX, RX and GND) to an external card. This card is optional and therefore the pins of UART1 could be floating.

I initialize the UART1 in this way

Code: Select all

	
		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
	};
	uart_param_config(UART_NUM_1, &uart_config);
	//Set UART pins: TX gpio_27, RX gpio_25 (-1: default pin, no change.)
	uart_set_pin(UART_NUM_1, GPIO_NUM_27, GPIO_NUM_25, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
	//Install UART driver
	err = uart_driver_install(UART_NUM_1, GSM_UART_BUFFER * 2, 0, 0, NULL, 0); //tx_buffer_size = 0 wait until all data has been sent out

	ESP_LOGI(TAG_GSM, "uart_driver_install:%d", err);

	//Create a task to handler UART event from ISR
	xTaskCreate(GSM_uartTask, "u_auxTask", 3300, NULL, 10, NULL);
So RX pin is GPIO25. In GSM_uartTask I read the uart in this way

Code: Select all

int len = uart_read_bytes(UART_NUM_1, dtmp, GSM_UART_BUFFER, 100 / portTICK_RATE_MS);
If the card is connected everything is working, but if the the card is not present there are spurios readings.

We don't have external pullup but rely only to internal pull-up (which is setup by "uart_set_pin" function).
Checking with oscilloscoper I can see there are some spurios glicth on GPIO_NUM_25 (RX pin of UART1) when another task reads the ADC1 (once every 1 second). In particular I read 6 channels of ADC1 and I get 6 glitches on GPIO_NUM_25.
Those glitches trigger the UART1 reading spurios characters. If the ADC task is not started, the glitches never happen.
I have checked voltage supply is OK and it doesn't have any glitch.

Is there any reason why ADC1 reading should affect a GPIO?

Re: Spurios UART1 reading

Posted: Tue Apr 24, 2018 11:56 am
by WiFive

[SOLVED] Re: Spurios UART1 reading

Posted: Tue Apr 24, 2018 12:48 pm
by davdav
That worked. Thanks @WiFive