1. Why Is Serial Communication So Popular?
When working on microcontroller products, the most commonly used method is serial communication. For any microcontroller peripherals, the priority is to choose those with serial port functionality, such as Bluetooth modules, WIFI modules, 4G modules, electric meters, and displays.
Click the image for a detailed introduction to serial ports
Both parties agree on the same speed, such as 115200bps, and send data in the form of data packets, transmitting 8 bits at a time, which is one byte of data.
2. Disadvantages of Serial Communication
3. Only supports one-to-one communication, cannot support one-to-many communication.
Therefore, to address these shortcomings, we need to adopt other methods to compensate for the limitations of serial communication.
3. RS232, RS485, SPI Communication
3.1. RS232, RS485
As I mentioned earlier, when the distance between the microcontroller and the peripheral is short, normal communication can occur. However, if we need to transmit data over long distances, it can easily be affected by interference, leading to communication errors. This is when humans ingeniously invented RS232 and RS485 communication.
-
RS232 communication can reach a distance of about 30m;
-
In ideal conditions, RS485 communication can exceed 1000m, and multiple loads can be connected on the 485 bus.
Click the image for a detailed introduction to RS485
Typically, the maximum baud rate for serial communication is 115200
If there is no parity bit, it should be divided by 10 to get the number of bytes per second:115200÷10= 11520 (bytes/second). Dividing by 1024 gives the number of KB per second:11520÷1024=11.25 (KB/second).
If there is one parity bit, it should be divided by 11 to get the number of KB per second: 115200÷11÷1024= 10.27 (KB/second).
Thus, the speed of serial communication is quite slow. This slowness is due to the early microcontrollers having lower frequencies and poor clock precision, making it difficult for the two parties to maintain an identical baud rate. If the speed is too fast, communication errors occur.
3.2. SPI
What if we add a clock signal between the two communicating parties? We don’t have to agree on the same speed; we can simply send and receive data based on the rising edge of the clock signal, significantly increasing the communication speed, which led to the creation of SPI communication, capable of easily exceeding 10M.
Click the image for a detailed introduction to SPI
3.3. I2C
If our microcontroller needs to control multiple peripherals simultaneously, using many serial ports for separate connections is quite wasteful. If multiple peripherals can be connected on a single communication line, it would be a significant resource saver, leading to the creation of I2C.
Due to recent changes in WeChat public platform push rules, many readers have reported not seeing updated articles in a timely manner. According to the latest rules, it is recommended to frequently click on ‘Recommended Reading, Sharing, and Bookmarking’, to become a regular reader.
Recommended Reading:
-
Samsung Withdraws Investment! Out of Money?
-
Firing Employees and Closing Stores, New Car Discounts! Is Another New Car Manufacturer Going to Fail?
-
Meizu Officially Announces: No Longer Making Smartphones!
-
Breaking News! Huawei Raided in France
-
Heavyweight! Another Semiconductor Giant Officially Withdraws from China
Please click 【View】 to give the author a thumbs up
