Hello everyone i try to receive the data from the uartt but i cannot receive the data from the uart but i am able to write the data in the uart can someone please help me to receive the data from the uartProgram:
void receive_uart_response(void)
{
uint8_t rx_buffer[UART_BUFFER_SIZE] = {0};
fsp_err_t err = FSP_SUCCESS;
SEGGER_RTT_WriteString(0, "Waiting for UART response (2 seconds timeout)...\n");
TickType_t start_time = xTaskGetTickCount();
TickType_t timeout_ticks = pdMS_TO_TICKS(2000); // 2 seconds timeout
while ((xTaskGetTickCount() - start_time) < timeout_ticks)
err = g_uart0.p_api->read(&g_uart0_ctrl, rx_buffer, sizeof(rx_buffer));
if (err == FSP_SUCCESS)
SEGGER_RTT_WriteString(0, "Received Data: ");
SEGGER_RTT_Write(0, rx_buffer, sizeof(rx_buffer));
SEGGER_RTT_WriteString(0, "\n");
// Clear the buffer for the next read
memset(rx_buffer, 0, sizeof(rx_buffer));
}
else if (err != FSP_ERR_INSUFFICIENT_DATA)
SEGGER_RTT_printf(0, "UART read error: %d\n", err);
return;
vTaskDelay(pdMS_TO_TICKS(10)); // Small delay to prevent tight loop
SEGGER_RTT_WriteString(0, "UART receive operation completed.\n");