Skip to main content
Associate II
September 29, 2023
Solved

DOUBT:UART SERIAL RECEIVE

  • September 29, 2023
  • 7 replies
  • 4457 views

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

    This topic has been closed for replies.
    Best answer by Issamos

    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

    7 replies

    Issamos
    IssamosBest answer
    Super User
    September 29, 2023

    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

    Associate II
    September 30, 2023

    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.

    Issamos
    Super User
    September 30, 2023

    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

    KDJEM.1
    ST Technical Moderator
    September 29, 2023

    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 "Best answer" on the reply which solved your issue or answered your question.
    TDK
    September 29, 2023

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