In serial communication, 1-byte data, for example, is split into multiple bits of data and sent bit by bit. The receiving side must reassemble the data that has been sent in this way into the original data. During this process, the original data cannot be restored if there is no way to tell what part of the received signal contains valid data and where coherent data (byte data) begins and ends.
(a) Synchronous communication
A simple method for indicating which part represents valid data is to simultaneously exchange a signal for that purpose. The signal for this purpose is the (serial) clock signal. As shown in the synchronous communication example below, if you set the serial data to change at the falling edges of the clock, you can fetch the correct data at the rising edges of the clock.
Now, the position of the correct data (bits) has become clear. This state is expressed as "bit synchronization has been achieved." A communication method that synchronizes bits by exchanging clock signals in this way is called (clock) synchronous communication. Normally, the synchronous communication function that is built into a microcontroller exchanges clock signals only during data transfer. Therefore, if no mistake is made in the startup sequence, it becomes clear where the beginning of the data is and where the data for one character ends (this is called character synchronization or byte synchronization).
In this method, the transfer rate is determined by the clock signals that are exchanged simultaneously with data, and therefore it can be set relatively freely and high. However, since clock signals are exchanged, data will end up being shifted if receiving of even a single clock signal is missed. Consequently, if receiving starts in the middle of the data being sent, for example, the data bit position will end up being shifted, and from then on, correct data cannot be reproduced (received). To avoid this problem, it is necessary to initialize the serial controller when communication is paused.
In the case of synchronous communication used as a general communication method, the clock signal is continuous. Therefore, it is not possible to tell where data starts and ends. To solve this issue, character synchronization is achieved by exchanging synchronous characters, making the start and end of data clear. In this method, synchronous characters are being sent when no data is being sent. As explained here, the operation can differ even for the same synchronous communication.
(b) Start-stop synchronous communication (asynchronous communication)
Start-stop synchronous communication (asynchronous communication) is a communication method that exchanges data without using serial clock signals. In this method, since only data signals are exchanged, the transfer rate must be matched between the transmitting side and receiving side in advance. The data (bit) interval has now been determined, but this alone cannot indicate the timing that shows where the correct data is.
In order to reproduce the correct timing from the data signals themselves, a part for determining the timing is needed besides the data portion. For this reason, control areas called start bits and stop bits are added to the signals and exchanged.
As shown in the above figure, adding a start bit at the head makes the start of the signal clear, making it possible to synchronize bits and characters. Additionally, to enable the start bit of each character, it is necessary to add a stop bit to the end of the data and set the serial data high once data is completed, and to maintain the high state while there is no communication data.
To detect the start bit at the correct timing, the receiving side needs to monitor the serial data at an interval that is shorter than the bit interval. For this reason, it is not possible to achieve a communication speed that is as high as that in synchronous communication.
Note that there is essentially no difference between a start bit and a bit in which the data is 0. Consequently, if receiving starts in the middle of the data being sent, incorrect data will end up being received. In this case, if there is a part not containing 1-character worth of data in the middle, it will become possible to receive data correctly from there on.
Basically, in start-stop synchronous communication, the transfer rate must be matched between the transmitting side and receiving side in advance. However, by sending certain data (normally 55H) at the head of communication, the transfer rate can be matched. It is also possible for the receiving side to determine the transfer rate by using a timer counter to measure the signal amplitude of the serial data. Furthermore, if the transfer rate to be used is somewhat limited, such as 9,600, 19,200, or 38,400 baud, the highest transfer rate possible is used for receiving. The transfer rate is estimated based on the number of data segments received and the data values.