How will be the integers sent though UART

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

How will be the integers sent though UART

1,584 次查看
ddpd
Contributor III

I 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?

Thanks in advance

标签 (1)
标记 (3)
1 回复

1,155 次查看
Stano
NXP Employee
NXP Employee

Hello David,

as you know the UART interface has defined protocol, which consists of:

1. START bit

2.Data array - usually 8-bit (one byte), but could be 9-bit also,

3.Parity bit

4.STOP bit.

So the information is covered in the Data  = one byte. It is up to you what these data will represent. It can be "read" as ASCII character, as hex format number (0x..), as decimal number (0 - 255) or something else.

So what is placed into UART Tx buffer, the same will be received from the UART RX buffer on opposite site. The final interpretation depends on the system using the transferred data.

Best Regards,

Stano.