Page 1 of 1

UART Config Issue

Posted: Tue Mar 24, 2020 7:31 pm
by Pallav Aggarwal
[Codebox]
#define UART2_TX_PIN 17
#define UART2_RX_PIN 16
char uartTxBuff[11] = "INDIA WON\n";

inside the main function
//Initialize the UART
//Baud Rate
//Parity
//Data Bits
//Stop Bits
//Flow Control
uart_set_baudrate(UART_NUM_2, 115200);
uart_set_parity(UART_NUM_2, UART_PARITY_DISABLE);
uart_set_word_length(UART_NUM_2, UART_DATA_8_BITS);
uart_set_stop_bits(UART_NUM_2, UART_STOP_BITS_1);
uart_set_hw_flow_ctrl(UART_NUM_2, UART_HW_FLOWCTRL_DISABLE, 0);

// Set Uart Pins: TX, RX, RTS, CTS)
uart_set_pin(UART_NUM_2, UART2_TX_PIN, UART2_RX_PIN, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
uart_driver_install(UART_NUM_2, 1024 * 2, 0, 0, NULL, 0);
While(1)
{
uart_write_bytes(UART_NUM_2, uartTxBuff, 10);
vTaskDelay(1000 / portTICK_PERIOD_MS);
printf("Hello Pallav!\n");
}
[/Codebox]

I am able to see Hello Pallav getting printed in make monitor but on GPIO 17 I don't get any data out, I am checking with Logic Analyzer.

When I did UART configuration like following, it works

uart_config_t uart_config = {
.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,
};
// Configure UART parameters
ESP_ERROR_CHECK(uart_param_config(UART_NUM_2, &uart_config));


Anyone have an idea where I am going wrong in fist place?

Re: UART Config Issue

Posted: Thu Mar 26, 2020 1:51 pm
by WiFive
Probably not calling uart_module_enable

Re: UART Config Issue

Posted: Fri Mar 27, 2020 11:53 am
by Pallav Aggarwal
what is that?
which API you mean?