Some experiences in debugging serial ports

**1.** If two serial ports are used, generally one is for serial port printing information (referred to as debugging serial port), and the other should be used for communication with sensors or wireless communication modules. It is best to use modular programming, that is, to Write a separate file for debugging the serial port, which is convenient for future transplantation and is not easy to confuse the two.
Insert image description here
Second, when using the serial port, you must add a pin multiplexing connection, otherwise you will not be able to debug at all. This pit took a week to climb. come out

		/* 将USART1_GPIO复用功能连接 */
		GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_1);
		GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_1);

**3.** When looking for errors, you should write them one by one from the beginning, one by one, and do
this every time. Otherwise, you will not know what you changed later. In the end, even if you changed the right place, the results will be different in other places. I tried to change it carefully, but in the end it still couldn't be adjusted. One suggestion is to add notes and date stamp each time you make a change.

Guess you like

Origin blog.csdn.net/weixin_45950842/article/details/117252464