This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How will be the integers sent though UART

have to write and read integers from the UART peripheral.

In what format does the UART transmits the integer? Is it in ascii? Even if I send characters as numbers (0 to 255) how is it transmitted?

Do I need to internally convert the data read from UART from ascii to int ?

I am confused over the answers from different blog. Could anyone suggest a link or provide answer.

I tried different things like programmed the board to continuously transmit the data. If I transmit the character from the board's UART to the putty, it displays in the putty as a character but it won't display in my c code written in linux. So what should be the format specifier?

  • Hi Dino,

     The UART module does not know what is ascii or integer. It just transmits what is written to the transmit shift register by the application.  In order for your terminal window to display a character '0' you need to write to the UART transmit shift register with a value of 0x30 which is the ASCII code for '0'. When you type a 'character 0' in the terminal window and expect the MCU to process this '0' as an integer '0' you will need to convert it. 

  • "When you type a 'character 0' in the terminal window and expect the MCU to process this '0' as an integer '0' you will need to convert it."

    If it is not considered as 0 at the MCU, it means that character 0 is not interpreted in the right way. Hence the need for conversion. So there is some format expected by the UART shift register? Also how to do the conversion?

     

  • Hi Dino,
    Your software needs to convert it. For example, the ASCII code for character '0' is 0x30. If you receive a data of value 0x30 in the UART receive buffer then you will subtract 0x30 to get the integer value of 0.