It can be seen that bit 765 replaces bit 654 and bit 7 is set to 1 after bit 4 is lost
I don't know the details, but I can only guess the reason One possibility is that the baud rate error is large. You can try to reduce the baud rate, or you can not reduce the baud rate to other baud rates, but you can deliberately slow the transmission baud rate by 5%~10%. Check the phenomenon first
From the perspective of hardware, First, look at the waveform of the rx pin of the mcu, and confirm that the data sent by the computer has entered the rx Then check whether the rx interrupt is not on, whether the n, 8, 1 and other things are the same as the computer, and whether the rx interrupt is entered. Then, there is no such thing. Replace it. The rx circuit is damaged
You can first eliminate the hardware problem and check whether there is a problem with the hardware. I suggest you read a book, Wu Jianying's practical introduction to the single-chip microcomputer, which can be downloaded to the electronic version. The method of communication debugging is described in great detail.
Because the interrupt was started but the interrupt program was not written, the interrupt jumped back to the main function after it was sent, and the generated interrupt flag was not clear, so it was sent twice