Hi, Nadia,
As Frank said it was correct behavior of MCU which stuck in the while() line in polling mode.
As you know there are three methods to transfer data: polling mode, interrupt mode and DMA mode, the while ((base->FIFOSTAT & USART_FIFOSTAT_RXNOTEMPTY_MASK) == 0U) belongs to polling mode, it continues to poll if the USART_FIFOSTAT_RXNOTEMPTY_MASK bit in base->FIFOSTAT is set, it does nothing else, that is why is it is calling USART_ReadBlocking.
I suggest you use interrupt mode, when the USART receives a character, the USART_FIFOSTAT_RXNOTEMPTY_MASK bit in base->FIFOSTAT register is set immediately, the event can trigger an interrupt, then the MCU will stop the current task and enter the ISR of the USART and execute the ISR. In the ISR, you can read the character from receiver. You can call the
hal_uart_status_t HAL_UartTransferReceiveNonBlocking(hal_uart_handle_t handle, hal_uart_transfer_t *transfer)
{
hal_uart_state_t *uartHandle;
status_t status;
assert(handle);
assert(transfer);
assert(HAL_UART_TRANSFER_MODE);
uartHandle = (hal_uart_state_t *)handle;
status = USART_TransferReceiveNonBlocking(s_UsartAdapterBase[uartHandle->instance], &uartHandle->hardwareHandle,
(usart_transfer_t *)transfer, NULL);
return HAL_UartGetStatus(status);
}
Hope it can help you
BR
XiangJun Rong