esp32-s3-korvo-2 uart does not receive
Posted: Tue Feb 27, 2024 11:18 pm
I am using a esp32-s3-korvo-2. It has tx0 and rx0 pins available on the board. I am trying to use the uart through these pins but Korvo only sends data and doesn't receive anything. I checked the pins using a logic analyzer and I can see the data coming to the rx0.
here is the loopback example that I am running. I'm wondering if there is any hardware limitation or any issue with my code.
here is the loopback example that I am running. I'm wondering if there is any hardware limitation or any issue with my code.
Code: Select all
static void echo_task(void *arg)
{
/* Configure parameters of an UART driver,
* communication pins and install the driver */
uart_config_t uart_config = {
.baud_rate = ECHO_UART_BAUD_RATE,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
.source_clk = UART_SCLK_DEFAULT,
};
int intr_alloc_flags = 0;
#if CONFIG_UART_ISR_IN_IRAM
intr_alloc_flags = ESP_INTR_FLAG_IRAM;
#endif
ESP_ERROR_CHECK(uart_driver_install(ECHO_UART_PORT_NUM, BUF_SIZE * 2, 0, 0, NULL, intr_alloc_flags));
ESP_ERROR_CHECK(uart_param_config(ECHO_UART_PORT_NUM, &uart_config));
ESP_ERROR_CHECK(uart_set_pin(ECHO_UART_PORT_NUM, ECHO_TEST_TXD, ECHO_TEST_RXD, ECHO_TEST_RTS, ECHO_TEST_CTS));
// Configure a temporary buffer for the incoming data
uint8_t *data = (uint8_t *) malloc(BUF_SIZE);
// Write data to UART.
char* test_str = "This is a test string.\n";
uart_write_bytes(ECHO_UART_PORT_NUM, (const char*)test_str, strlen(test_str));
while (1) {
// Read data from the UART
int len = uart_read_bytes(ECHO_UART_PORT_NUM, data, (BUF_SIZE - 1), 100);
uart_write_bytes(ECHO_UART_PORT_NUM, (const char *) data, len);
// Write data back to the UART
//
if (len) {
data[len] = '\0';
ESP_LOGI(TAG, "Recv str: %s", (char *) data);
}
}
}