UART Config Issue

Pallav Aggarwal
Posts: 5
Joined: Wed Mar 18, 2020 5:32 pm

UART Config Issue

Postby Pallav Aggarwal » Tue Mar 24, 2020 7:31 pm

[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?
Best Regards
Pallav Aggarwal
https://pallavaggarwal.in/

WiFive
Posts: 2887
Joined: Tue Dec 01, 2015 7:35 am

Re: UART Config Issue

Postby WiFive » Thu Mar 26, 2020 1:51 pm

Probably not calling uart_module_enable

Pallav Aggarwal
Posts: 5
Joined: Wed Mar 18, 2020 5:32 pm

Re: UART Config Issue

Postby Pallav Aggarwal » Fri Mar 27, 2020 11:53 am

what is that?
which API you mean?
Best Regards
Pallav Aggarwal
https://pallavaggarwal.in/

Who is online

Users browsing this forum: Baidu [Spider], sylwester and 45 guests