2023-09-29 03:49 AM
I'm trying to Receive a message "hello" from serial monitor and viewing it on Live expression,but message is not coming as word. It is coming as single letter- H E L L O.
char msg[20]="hello\r";
HAL_UART_Receive(&huart2,msg,sizeof(msg),1000);
i am using this code.
Solved! Go to Solution.
2023-09-29 04:50 AM - edited 2023-09-29 05:43 AM
Hello @Arjun_Bansal
This is normal because you are sending an array of char and you are going to receive an array of char (every char take a byte of this array). Use UART_transmit to review it on the same serial monitor and you will see the full string.
Best regards.
II
2023-09-29 04:50 AM - edited 2023-09-29 05:43 AM
Hello @Arjun_Bansal
This is normal because you are sending an array of char and you are going to receive an array of char (every char take a byte of this array). Use UART_transmit to review it on the same serial monitor and you will see the full string.
Best regards.
II
2023-09-29 05:39 AM
Hello @Arjun_Bansal and welcome to STCommunity :),
I advise you to take a look to these wikis:
These articles explain what is UART and how to use it through examples
I hope this help you.
Kaouthar
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-09-29 05:39 AM
"DDD" corresponds to what is in msg, so no issue there. No reason the code you posted can't work.
Show your actual code in the place it's being used.
2023-09-29 09:56 PM
I'm just getting started with it. Please let me know how to receive a string from serial monitor and see it as string on live expression. I MEAN HOW TO DECLARE A STRING.
2023-09-29 10:21 PM - edited 2023-09-30 07:13 AM
To receive a string, you are doing exactly what you have to do. The reception will stay in this form. To understand more, take a look at this video.
Strings are declared as an array of char.
Best regards.
II
2023-09-30 06:49 AM
> You can declare a string directly like this:
> String a;
Huh? Maybe time to recalibrate the AI.
2023-09-30 07:12 AM
No, no is just a typo not an AI Error. Thank you for your feedback.
Best regards.
II