cancel
Showing results for 
Search instead for 
Did you mean: 

DOUBT:UART SERIAL RECEIVE

Arjun_Bansal
Associate III

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.

ADC.png

1 ACCEPTED SOLUTION

Accepted Solutions
Issamos
Lead II

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

View solution in original post

7 REPLIES 7
Issamos
Lead II

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

KDJEM.1
ST Employee

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.

TDK
Guru

"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.

If you feel a post has answered your question, please click "Accept as Solution".

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.

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

> You can declare a string directly like this: 

> String a;

Huh? Maybe time to recalibrate the AI.

 

If you feel a post has answered your question, please click "Accept as Solution".

No, no is just a typo not an AI Error. Thank you for your feedback.

Best regards.

II