ARM under the Common Communication Interface

2019-12-15

Keywords: uart, spi, i2c


 

Communication between the devices can be generally divided into the following two types:

1, a serial communication;

2, parallel communication;

 

Wherein the serial communication can be divided into the following categories:

1、UART;

It requires two wire communication, it is a full duplex communication mode.

 

 

2、I2C;

It is also fundamentally two communication wires, but it belongs to a half-duplex communication mode.

 

 

3, the SPI;

It requires three communication wire, full-duplex communication mode.

 

Serial communication protocols:

Serial communication protocol is a communication protocol commonly used in embedded development, its communication protocol structure shown below:

 

Since the occurrence of the communication data is random when no data transceiver serial communication lines are in an idle state, an idle state is generally expressed at a high level. When you need to send data, a serial communication line must be "action" in order to allow communication to inform the recipient that we want to start sending data, and this data is received just be ready to receive data. This data is sent before the start of "action" is called "start bit." Usually down to the level of a period of time to indicate the start of communication flag.

 

Serial communication disadvantage is that a lower communication rate, and error-prone.

 

I2C communication protocols:

I2C communication is an improved version of the UART communication. Although it also uses two wire communication, but there is a dedicated line for transmitting "clock signals". A standard clock signal is called high and low alternating square wave. Communications both to the clock signal as a standard read and write data. For example, I2C stipulates that the sender is sent only when the data clock signal at the low level state, and the receiver will only to read the data at the rising edge of the clock signal phase. This rigorous separate read and write modes can ensure the accuracy of communication. At the same time, and because only a single line I2C communication, which also limits died I2C can only be used as a half-duplex communication mode.

 

SPI protocol:

In front of the UART protocol I2C communication have their respective advantages and disadvantages. SPI is the product of their combined advantages of both. SPI communications protocol can only achieve full-duplex communication, but also to ensure the accuracy of communication. While its communication speed is the fastest of the three.

 

It is in front of several common serial communications protocol. A transceiver serial data communication requires a "orderly", the communication can be done in parallel "disorder" of data transmission and reception. This different communication modes, resulting in a direct parallel communication speed is much higher than the serial communication. But at the expense of the parallel communication it is expensive, it requires far more than the communication line serial communication.

 

串并行通信模式各自都有它们的优缺点,在实际使用过程中需要结合自身需要来选择应用。

 

在ARM编程中,可以直接对地址进行赋值而不需要创建一个变量,如:

*(volatile unsigned int *)0x11400020 = 0x22;

上面的 0x11400020 即表示ARM芯片中某个寄存器的地址,这条语句的意思就是给这个地址所代表的寄存器赋值 0x22。当然这种编程方式其实并不适合在实际工作是使用。

 

在ARM下开发串口通信程序的步骤其实很简单:

1、根据原理图找到对应的CPU控制管脚;

2、根据芯片手册找到对应的寄存器;

3、配置串口通信寄存器的模式(功能选择、停止位、校验位、波特率等);

4、编写程序进行收发控制。

唯一的难点就在于阅读芯片手册与寄存器含义了。只要搞懂了这些寄存器的含义,配置正确了,串口通信程序也就很容易写了。

 

不止是串口通信,任何一种涉及到芯片寄存器的配置都是这种开发方式的。

 

另外,其实在ARM开发中,C语言中是可以直接调用汇编函数的,C语言中也可以直接嵌入汇编代码。

 


 

Guess you like

Origin www.cnblogs.com/chorm590/p/12045689.html