2023-11-28 11:44 AM - last edited on 2023-11-28 11:54 AM by Sarra.S
Hey, I would like to a string from terminal via UART in order to complete a challange given by Digi-Key YouTube channel in FreeRTOS tutorial playlist. Anyway, I want to take the whole string given by user in terminal, but I couldn't so far. I tried
HAL_UART_Receive(&huart2, (uint8_t*)rcvd_msg, MSG_LEN, 100);
however it didn't work. It can take only the first letter and nothing else. btw, I don't want to use interrupts in this case, so it is better to suggest something without interrupt.
Thanks for your answers.
2023-11-28 12:06 PM - edited 2023-11-28 12:11 PM
Hello @akoluacik
I would say consider using HAL_UART_Receive_IT or HAL_UART_Receive_DMA instead, but since you don't want to use interrupts (despite the fact that it is a convenient option), set UART reception in circular DMA mode
Also which STM32?
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2023-11-28 01:03 PM
Perhaps wait longer than 100ms for the message to come through. Unclear how it's being sent from the terminal program, but it sounds like it's one letter at a time, as you type them.
Or read them in one character at a time into a buffer.
2023-12-02 12:53 AM
I don't wanna make complex the program since it is just a homework, but will consider it if cannot find a solution.
BTW, I didn't think it is important but my board is STM32F411RE.
2023-12-02 12:55 AM
Actually, I am using RealTerm, what I want to do is it gets all characters till it sees a \r character, but it does is only one character and it assigns to all indexes of a buffer.
2023-12-02 06:21 AM
You can also try HAL_UARTEx_ReceiveToIdle which is better than the regular HAL implementation.
2023-12-02 06:57 AM
> It can take only the first letter and nothing else
Candidate #1: Receiver overflow. Check and clear the overflow OR disable the overflow detection if your STM32 has this feature.
2023-12-02 01:35 PM
It depends on your terminal program. If it sends each character as you type then you may only get 1 or 2 at most characters before it times out in 100ms. If it's one character at a time, then HAL_UART_Receive is not what you want to use.