s3c2440 bare metal - UART programming 1 - UART hardware introduction and transmission principle

Publisher:快乐家庭Latest update time:2024-07-08 Source: elecfans Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1.Uart hardware introduction

UART stands for Universal Asynchronous Receiver and Transmitter. UART is mainly used for:


1. Print debugging

2. Data Transmission

The serial port can be connected through three wires: send, receive, and ground.


TxD of pc -> RxD of arm (UART write)

ARM's TxD -> PC's RxD (UART read)

2.uart parameters and formats

Baud rate: Indicates how many bits are transmitted per second, bits per second (bps). Generally, the baud rate options are 9600, 19200, 115200, etc.

Format:


Start bit: A logic "0" signal is sent first, indicating the beginning of data transmission.

Data bits: can be 5 to 8 bits of logical "0" or "1". Usually 7 bits, just enough to transmit all ASCII codes.

Check digit:

Odd parity: (parity bit + data bit) makes the number of "1" bits an odd number

Even parity: (parity bit + data bit) makes the number of "1" bits an even number

For example:

The ASCII value of 'A' is 0x41, which is 01000001 in binary. For odd parity, write '1' in the check bit, and for even parity, write '0' in the check bit.

Stop bit: It is the end mark of a character data.

3. How does UART transmit a character 'A'

The ASCII value of 'A' is 0x41, which is 01000001 in binary. How do we send these 8 bits of data to a PC?


1. Both parties agree on the baud rate (the time each bit takes)

2. Specify the transmission protocol

Now in this mode: arm's TxD -> pc's RxD (UART read)


1. The time when arm pulls down the uart bus 1 bit (start bit)

2. ARM drives the TxD level in turn according to the data bit, and PC reads the UART bus in turn. The data reaches the RxD pin of PC, and PC obtains the data bit in turn.

In order to transmit data over long distances, our PC uses RS-232 logic levels, while the ARM development board uses TTL/CMOS logic levels. Here we first explain what TTL logic levels are and what RS-232 logic levels are.


TTL/CMOS logic levels:


0 (low level 0-0.7v) represents logic '0'

1 (high level 2-5v) indicates logic '1'

RS-232 Logic Levels:


(+3V ~ +12V) indicates logic '0'

(-12V ~ -3V) indicates logic '1'

TTL logic level waveform:


RS232 logic level waveform:


Then the timing starts after the start signal begins, and the arm puts 1 bit of data to TxD every clock, and the pc also gets 1 bit of data from RxD.


arm pc

TxD=data[0:], data[0:]=RxD

TxD=data[1:], data[1:]=RxD

...

TxD=data[7:], data[7:]=RxD

Why RS232?


We know that the difference between the logic '0' and logic '1' of RS232 is larger than that of TTL/CMOS, so the logic level is not easily reversed, and it can be transmitted over a longer distance, so it is more commonly used in industry.


Therefore, the data obtained by the PC above is incorrect, so we need a TTL to RS232 level conversion chip.


4.How does the ARM chip send and receive data?


Sending data:


The memory puts the data into the transmit FIFO (64 bytes), and sends the data one bit at a time to TXDn through the transmit shifter, so that the PC can get the data from the bus one by one.

Receiving data:


When the TXDn terminal of the PC sends the data to the bus, the arm obtains the pin level of RXDn and gets the data in turn, puts it into the receive shifter bit by bit, then puts it into the FIFO and writes it to the memory.

Of course, you can also not use fifo and let the memory interact with the shifter directly, but this will waste memory resources, the memory frequency is very high, and reduce the memory throughput


Reference address:s3c2440 bare metal - UART programming 1 - UART hardware introduction and transmission principle

Previous article:s3c2440 bare metal - UART programming - 2 - UART programming implementation
Next article:s3c2440 bare metal - clock programming - 2 - configure clock register

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号