{"id":76698,"date":"2026-02-23T04:17:19","date_gmt":"2026-02-22T20:17:19","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/76698.html"},"modified":"2026-02-23T04:17:19","modified_gmt":"2026-02-22T20:17:19","slug":"%e6%b1%9f%e7%a7%91%e5%a4%a7%e7%ac%94%e8%ae%b0-usart%e4%b8%b2%e5%8f%a3%e9%80%9a%e4%bf%a1%e5%8d%8f%e8%ae%ae%e4%b8%8estm32%e5%ae%9e%e6%88%98%e9%85%8d%e7%bd%ae","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/76698.html","title":{"rendered":"\u6c5f\u79d1\u5927\u7b14\u8bb0\u2014USART\u4e32\u53e3\u901a\u4fe1\u534f\u8bae\u4e0eSTM32\u5b9e\u6218\u914d\u7f6e"},"content":{"rendered":"<h3>1. USART\u4e32\u53e3\u901a\u4fe1\u57fa\u7840\u6982\u5ff5<\/h3>\n<p>\u5927\u5bb6\u597d&#xff0c;\u6211\u662f\u6c5f\u79d1\u5927\u7684\u8001\u5b66\u957f&#xff0c;\u4eca\u5929\u6765\u804a\u804aUSART\u4e32\u53e3\u901a\u4fe1\u534f\u8bae\u548cSTM32\u7684\u5b9e\u6218\u914d\u7f6e\u3002\u5982\u679c\u4f60\u521a\u5f00\u59cb\u63a5\u89e6\u5d4c\u5165\u5f0f\u5f00\u53d1&#xff0c;\u4e32\u53e3\u901a\u4fe1\u7edd\u5bf9\u662f\u4f60\u7b2c\u4e00\u4e2a\u8981\u638c\u63e1\u7684\u901a\u4fe1\u534f\u8bae&#xff0c;\u56e0\u4e3a\u5b83\u7b80\u5355\u5b9e\u7528&#xff0c;\u51e0\u4e4e\u6240\u6709\u7684\u5fae\u63a7\u5236\u5668\u90fd\u652f\u6301\u8fd9\u4e2a\u529f\u80fd\u3002<\/p>\n<p>USART\u7684\u5168\u79f0\u662fUniversal Synchronous\/Asynchronous Receiver\/Transmitter&#xff0c;\u4e2d\u6587\u53eb\u901a\u7528\u540c\u6b65\u5f02\u6b65\u6536\u53d1\u5668\u3002\u7b80\u5355\u6765\u8bf4&#xff0c;\u5b83\u5c31\u662fSTM32\u5185\u90e8\u7684\u4e00\u4e2a\u786c\u4ef6\u6a21\u5757&#xff0c;\u80fd\u591f\u81ea\u52a8\u5e2e\u6211\u4eec\u5904\u7406\u6570\u636e\u7684\u53d1\u9001\u548c\u63a5\u6536\u3002\u4f60\u53ea\u9700\u8981\u628a\u6570\u636e\u6254\u7ed9\u5b83\u7684\u6570\u636e\u5bc4\u5b58\u5668&#xff0c;\u5b83\u5c31\u4f1a\u81ea\u52a8\u751f\u6210\u5bf9\u5e94\u7684\u6570\u636e\u5e27&#xff0c;\u901a\u8fc7TX\u5f15\u811a\u53d1\u9001\u51fa\u53bb&#xff1b;\u540c\u6837\u5730&#xff0c;\u5f53RX\u5f15\u811a\u6536\u5230\u6570\u636e\u65f6&#xff0c;\u5b83\u4e5f\u4f1a\u81ea\u52a8\u89e3\u6790\u6570\u636e\u5e27&#xff0c;\u628a\u6570\u636e\u5b58\u5230\u5bc4\u5b58\u5668\u91cc\u7b49\u4f60\u6765\u53d6\u3002<\/p>\n<p>\u5728\u5b9e\u9645\u9879\u76ee\u4e2d&#xff0c;\u6211\u7ecf\u5e38\u7528\u4e32\u53e3\u6765\u505a\u8c03\u8bd5\u8f93\u51fa\u3002\u6bd4\u5982\u5f53\u7a0b\u5e8f\u8fd0\u884c\u5230\u67d0\u4e2a\u5173\u952e\u70b9\u65f6&#xff0c;\u901a\u8fc7\u4e32\u53e3\u53d1\u9001\u4e00\u4e9b\u72b6\u6001\u4fe1\u606f\u5230\u7535\u8111\u4e0a&#xff0c;\u8fd9\u6837\u5c31\u80fd\u5f88\u76f4\u89c2\u5730\u77e5\u9053\u7a0b\u5e8f\u8fd0\u884c\u5230\u54ea\u91cc\u4e86\u3002\u53e6\u5916&#xff0c;\u5f88\u591a\u4f20\u611f\u5668\u6a21\u5757&#xff0c;\u6bd4\u5982\u6e29\u6e7f\u5ea6\u4f20\u611f\u5668\u3001\u9640\u87ba\u4eea\u7b49&#xff0c;\u4e5f\u5e38\u5e38\u901a\u8fc7\u4e32\u53e3\u6765\u4f20\u8f93\u6570\u636e\u3002\u6240\u4ee5\u638c\u63e1\u597d\u4e32\u53e3\u901a\u4fe1&#xff0c;\u5bf9\u4f60\u540e\u7eed\u7684\u5d4c\u5165\u5f0f\u5f00\u53d1\u4f1a\u6709\u5f88\u5927\u5e2e\u52a9\u3002<\/p>\n<h3>2. USART\u901a\u4fe1\u534f\u8bae\u8be6\u89e3<\/h3>\n<h4>2.1 \u6570\u636e\u5e27\u7ed3\u6784<\/h4>\n<p>\u4e32\u53e3\u901a\u4fe1\u7684\u6570\u636e\u662f\u4ee5\u5e27\u4e3a\u5355\u4f4d\u8fdb\u884c\u4f20\u8f93\u7684\u3002\u6bcf\u4e2a\u6570\u636e\u5e27\u5305\u542b\u8d77\u59cb\u4f4d\u3001\u6570\u636e\u4f4d\u3001\u53ef\u9009\u7684\u6821\u9a8c\u4f4d\u548c\u505c\u6b62\u4f4d\u3002\u8fd9\u79cd\u7ed3\u6784\u786e\u4fdd\u4e86\u5373\u4f7f\u5728\u6ca1\u6709\u65f6\u949f\u4fe1\u53f7\u7684\u60c5\u51b5\u4e0b&#xff0c;\u63a5\u6536\u65b9\u4e5f\u80fd\u6b63\u786e\u89e3\u6790\u6570\u636e\u3002<\/p>\n<p>\u8d77\u59cb\u4f4d\u603b\u662f\u4f4e\u7535\u5e73&#xff0c;\u5b83\u6807\u5fd7\u7740\u4e00\u5e27\u6570\u636e\u7684\u5f00\u59cb\u3002\u5f53\u901a\u4fe1\u7ebf\u8def\u5904\u4e8e\u7a7a\u95f2\u72b6\u6001\u65f6&#xff0c;\u5f15\u811a\u4fdd\u6301\u9ad8\u7535\u5e73\u3002\u8d77\u59cb\u4f4d\u7684\u4f4e\u7535\u5e73\u4ea7\u751f\u4e00\u4e2a\u4e0b\u964d\u6cbf&#xff0c;\u544a\u8bc9\u63a5\u6536\u8bbe\u5907&#xff1a;&#034;\u6ce8\u610f&#xff0c;\u6570\u636e\u8981\u5f00\u59cb\u4f20\u8f93\u4e86&#xff01;&#034;\u8fd9\u4e2a\u8bbe\u8ba1\u5f88\u5de7\u5999&#xff0c;\u6211\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\u5c31\u9047\u5230\u8fc7\u56e0\u4e3a\u6ca1\u6709\u6b63\u786e\u914d\u7f6e\u8d77\u59cb\u4f4d\u800c\u5bfc\u81f4\u901a\u4fe1\u5931\u8d25\u7684\u60c5\u51b5\u3002<\/p>\n<p>\u6570\u636e\u4f4d\u662f\u5b9e\u9645\u8981\u4f20\u8f93\u7684\u6709\u6548\u6570\u636e&#xff0c;\u901a\u5e38\u662f8\u4f4d&#xff08;\u4e00\u4e2a\u5b57\u8282&#xff09;&#xff0c;\u4f46\u4e5f\u53ef\u4ee5\u662f5\u52309\u4f4d\u3002STM32\u7684USART\u652f\u6301\u53ef\u914d\u7f6e\u7684\u6570\u636e\u4f4d\u957f\u5ea6&#xff0c;\u8fd9\u5728\u67d0\u4e9b\u7279\u6b8a\u5e94\u7528\u4e2d\u5f88\u6709\u7528\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f&#xff0c;\u6570\u636e\u4f4d\u7684\u4f20\u8f93\u662f\u4f4e\u4f4d\u5148\u884c\u7684&#xff0c;\u4e5f\u5c31\u662f\u8bf4&#xff0c;\u6700\u4f4e\u4f4d&#xff08;LSB&#xff09;\u5148\u53d1\u9001&#xff0c;\u6700\u9ad8\u4f4d&#xff08;MSB&#xff09;\u6700\u540e\u53d1\u9001\u3002<\/p>\n<p>\u6821\u9a8c\u4f4d\u7528\u4e8e\u9519\u8bef\u68c0\u6d4b&#xff0c;\u5e38\u89c1\u7684\u6709\u5947\u6821\u9a8c\u548c\u5076\u6821\u9a8c\u3002\u5947\u6821\u9a8c\u8981\u6c42\u6570\u636e\u4f4d\u548c\u6821\u9a8c\u4f4d\u4e2d&#034;1&#034;\u7684\u4e2a\u6570\u4e3a\u5947\u6570&#xff0c;\u5076\u6821\u9a8c\u5219\u8981\u6c42\u4e3a\u5076\u6570\u3002\u867d\u7136\u5947\u5076\u6821\u9a8c\u7684\u68c0\u9519\u80fd\u529b\u6709\u9650&#xff0c;\u4f46\u5bf9\u4e8e\u4e00\u822c\u7684\u5e94\u7528\u6765\u8bf4\u5df2\u7ecf\u8db3\u591f\u4e86\u3002\u6211\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\u901a\u5e38\u4f7f\u7528\u65e0\u6821\u9a8c&#xff0c;\u56e0\u4e3a\u5927\u591a\u6570\u60c5\u51b5\u4e0b\u901a\u4fe1\u73af\u5883\u8fd8\u662f\u6bd4\u8f83\u53ef\u9760\u7684\u3002<\/p>\n<p>\u505c\u6b62\u4f4d\u6807\u5fd7\u7740\u4e00\u5e27\u6570\u636e\u7684\u7ed3\u675f&#xff0c;\u5fc5\u987b\u662f\u9ad8\u7535\u5e73\u3002\u505c\u6b62\u4f4d\u4e0d\u4ec5\u7528\u4e8e\u5e27\u95f4\u9694&#xff0c;\u8fd8\u4e3a\u4e0b\u4e00\u6b21\u7684\u8d77\u59cb\u4f4d\u505a\u51c6\u5907\u2014\u2014\u5b83\u786e\u4fdd\u7ebf\u8def\u6062\u590d\u5230\u9ad8\u7535\u5e73\u72b6\u6001&#xff0c;\u8fd9\u6837\u4e0b\u4e00\u6b21\u8d77\u59cb\u4f4d\u624d\u80fd\u4ea7\u751f\u4e0b\u964d\u6cbf\u3002<\/p>\n<h4>2.2 \u6ce2\u7279\u7387\u4e0e\u540c\u6b65\u673a\u5236<\/h4>\n<p>\u6ce2\u7279\u7387\u662f\u4e32\u53e3\u901a\u4fe1\u4e2d\u6700\u91cd\u8981\u7684\u53c2\u6570\u4e4b\u4e00&#xff0c;\u5b83\u51b3\u5b9a\u4e86\u6570\u636e\u4f20\u8f93\u7684\u901f\u5ea6\u3002\u6ce2\u7279\u7387\u8868\u793a\u6bcf\u79d2\u4f20\u8f93\u7684\u7801\u5143\u6570\u91cf&#xff0c;\u5355\u4f4d\u662f\u6ce2\u7279&#xff08;Baud&#xff09;\u3002\u5728\u4e8c\u8fdb\u5236\u8c03\u5236\u4e0b&#xff0c;\u4e00\u4e2a\u7801\u5143\u5c31\u662f\u4e00\u4e2a\u6bd4\u7279&#xff0c;\u6240\u4ee5\u6ce2\u7279\u7387\u5c31\u7b49\u4e8e\u6bd4\u7279\u7387\u3002<\/p>\n<p>\u5982\u679c\u53d1\u9001\u65b9\u548c\u63a5\u6536\u65b9\u7684\u6ce2\u7279\u7387\u8bbe\u7f6e\u4e0d\u4e00\u81f4&#xff0c;\u5c31\u4f1a\u51fa\u73b0\u6570\u636e\u9519\u8bef\u3002\u6bd4\u5982\u53d1\u9001\u65b9\u4ee59600bps\u7684\u901f\u7387\u53d1\u9001\u6570\u636e&#xff0c;\u800c\u63a5\u6536\u65b9\u4ee519200bps\u7684\u901f\u7387\u63a5\u6536&#xff0c;\u90a3\u4e48\u63a5\u6536\u5230\u7684\u6570\u636e\u5c31\u5b8c\u5168\u662f\u4e71\u7801\u3002\u6211\u5728\u521d\u5b66\u65f6\u5c31\u72af\u8fc7\u8fd9\u4e2a\u9519\u8bef&#xff0c;\u8c03\u8bd5\u4e86\u597d\u4e45\u624d\u53d1\u73b0\u662f\u6ce2\u7279\u7387\u4e0d\u5339\u914d\u7684\u95ee\u9898\u3002<\/p>\n<p>STM32\u7684USART\u4f7f\u7528\u5206\u6570\u6ce2\u7279\u7387\u53d1\u751f\u5668\u6765\u4ea7\u751f\u7cbe\u786e\u7684\u6ce2\u7279\u7387\u3002\u8ba1\u7b97\u516c\u5f0f\u662f&#xff1a;USARTDIV &#061; fck \/ (16 * Baudrate)&#xff0c;\u5176\u4e2dfck\u662fUSART\u7684\u65f6\u949f\u9891\u7387\u3002STM32\u7684USART1\u6302\u8f7d\u5728APB2\u603b\u7ebf\u4e0a&#xff0c;\u800cUSART2\u3001USART3\u7b49\u6302\u8f7d\u5728APB1\u603b\u7ebf\u4e0a&#xff0c;\u6240\u4ee5\u5b83\u4eec\u7684\u65f6\u949f\u6e90\u53ef\u80fd\u4e0d\u540c&#xff0c;\u5728\u914d\u7f6e\u65f6\u9700\u8981\u6ce8\u610f\u3002<\/p>\n<h4>2.3 \u5de5\u4f5c\u6a21\u5f0f\u4e0e\u7535\u5e73\u6807\u51c6<\/h4>\n<p>USART\u652f\u6301\u5168\u53cc\u5de5\u901a\u4fe1&#xff0c;\u4e5f\u5c31\u662f\u8bf4\u53ef\u4ee5\u540c\u65f6\u8fdb\u884c\u53d1\u9001\u548c\u63a5\u6536\u3002\u8fd9\u662f\u56e0\u4e3a\u6709\u72ec\u7acb\u7684TX\u548cRX\u7ebf\u8def&#xff0c;\u53d1\u9001\u548c\u63a5\u6536\u4e92\u4e0d\u5e72\u6270\u3002\u76f8\u6bd4\u4e4b\u4e0b&#xff0c;I2C\u548cSPI\u7b49\u534f\u8bae\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\u53ea\u80fd\u662f\u534a\u53cc\u5de5\u3002<\/p>\n<p>\u4e32\u53e3\u901a\u4fe1\u7684\u7535\u5e73\u6807\u51c6\u4e3b\u8981\u6709TTL\u7535\u5e73\u548cRS-232\u7535\u5e73\u3002TTL\u7535\u5e73\u75280V\u8868\u793a\u903b\u8f910&#xff0c;3.3V\u62165V\u8868\u793a\u903b\u8f911&#xff1b;\u800cRS-232\u7528\u7535\u5e73\u7528-3V\u5230-15V\u8868\u793a\u903b\u8f911&#xff0c;&#043;3V\u5230&#043;15V\u8868\u793a\u903b\u8f910\u3002\u73b0\u5728\u5927\u591a\u6570\u5355\u7247\u673a\u90fd\u4f7f\u7528TTL\u7535\u5e73&#xff0c;\u5982\u679c\u9700\u8981\u548cRS-232\u8bbe\u5907\u901a\u4fe1&#xff0c;\u5c31\u9700\u8981\u4f7f\u7528MAX232\u4e4b\u7c7b\u7684\u7535\u5e73\u8f6c\u6362\u82af\u7247\u3002<\/p>\n<p>\u5728\u5b9e\u9645\u8fde\u63a5\u65f6&#xff0c;\u4e00\u5b9a\u8981\u8bb0\u4f4fTX\u63a5RX&#xff0c;RX\u63a5TX&#xff01;\u8fd9\u4e2a\u770b\u4f3c\u7b80\u5355\u7684\u89c4\u5219&#xff0c;\u6211\u5374\u89c1\u8fc7\u4e0d\u5c11\u521d\u5b66\u8005\u63a5\u53cd\u3002\u5982\u679c\u4e24\u4e2a\u8bbe\u5907\u90fd\u6709\u72ec\u7acb\u4f9b\u7535&#xff0c;VCC\u53ef\u4ee5\u4e0d\u63a5&#xff1b;\u4f46\u5982\u679c\u5176\u4e2d\u4e00\u4e2a\u8bbe\u5907\u9700\u8981\u4f9b\u7535&#xff0c;\u5c31\u8981\u8fde\u63a5VCC\u7ebf\u3002\u63a5\u5730\u7ebf&#xff08;GND&#xff09;\u5219\u662f\u5fc5\u987b\u8fde\u63a5\u7684&#xff0c;\u8fd9\u786e\u4fdd\u4e86\u53cc\u65b9\u6709\u5171\u540c\u7684\u53c2\u8003\u5730\u7535\u4f4d\u3002<\/p>\n<h3>3. STM32\u7684USART\u5916\u8bbe\u914d\u7f6e<\/h3>\n<h4>3.1 \u786c\u4ef6\u7535\u8def\u8fde\u63a5<\/h4>\n<p>\u6211\u4eec\u5148\u6765\u770b\u770bSTM32\u4e0e\u5916\u90e8\u8bbe\u5907\u7684\u786c\u4ef6\u8fde\u63a5\u65b9\u5f0f\u3002\u6700\u5e38\u7528\u7684\u573a\u666f\u662fSTM32\u4e0e\u7535\u8111\u901a\u4fe1&#xff0c;\u8fd9\u901a\u5e38\u9700\u8981\u4e00\u4e2aUSB\u8f6c\u4e32\u53e3\u6a21\u5757&#xff0c;\u6bd4\u5982CH340G\u6216\u8005CP2102\u3002\u8fd9\u4e9b\u6a21\u5757\u4e00\u8fb9\u662fUSB\u63a5\u53e3&#xff0c;\u53ef\u4ee5\u63d2\u5728\u7535\u8111\u4e0a&#xff0c;\u53e6\u4e00\u8fb9\u662f\u4e32\u53e3\u5f15\u811a&#xff08;TX\u3001RX\u3001GND&#xff09;&#xff0c;\u4e0eSTM32\u7684\u4e32\u53e3\u5f15\u811a\u76f8\u8fde\u3002<\/p>\n<p>\u5728\u8fde\u63a5\u65f6&#xff0c;STM32\u7684TX\u5f15\u811a\u8981\u63a5\u6a21\u5757\u7684RX\u5f15\u811a&#xff0c;STM32\u7684RX\u5f15\u811a\u8981\u63a5\u6a21\u5757\u7684TX\u5f15\u811a&#xff0c;GND\u5bf9\u63a5GND\u3002\u5982\u679c\u6a21\u5757\u9700\u8981\u4f9b\u7535&#xff0c;\u8fd8\u8981\u8fde\u63a5VCC\u7ebf\u3002\u6211\u66fe\u7ecf\u9047\u5230\u8fc7\u56e0\u4e3a\u5fd8\u8bb0\u63a5GND\u800c\u5bfc\u81f4\u901a\u4fe1\u4e0d\u7a33\u5b9a\u7684\u60c5\u51b5&#xff0c;\u6240\u4ee5\u7279\u522b\u63d0\u9192\u5927\u5bb6&#xff1a;GND\u4e00\u5b9a\u8981\u63a5&#xff01;<\/p>\n<p>\u5bf9\u4e8eSTM32F103\u7cfb\u5217&#xff0c;USART1\u7684\u9ed8\u8ba4\u5f15\u811a\u662fPA9&#xff08;TX&#xff09;\u548cPA10&#xff08;RX&#xff09;&#xff0c;\u4f46\u4e5f\u53ef\u4ee5\u901a\u8fc7\u91cd\u6620\u5c04\u529f\u80fd\u5207\u6362\u5230\u5176\u4ed6\u5f15\u811a\u3002\u5176\u4ed6USART\u7684\u5f15\u811a\u4f4d\u7f6e\u9700\u8981\u67e5\u9605\u5177\u4f53\u82af\u7247\u7684\u6570\u636e\u624b\u518c\u3002\u5728\u8bbe\u8ba1PCB\u65f6&#xff0c;\u6211\u5efa\u8bae\u5728TX\u548cRX\u7ebf\u4e0a\u9884\u7559\u4e32\u8054\u7535\u963b\u7684\u4f4d\u7f6e&#xff0c;\u8fd9\u6837\u53ef\u4ee5\u5728\u4fe1\u53f7\u5b8c\u6574\u6027\u6709\u95ee\u9898\u65f6\u8fdb\u884c\u8c03\u6574\u3002<\/p>\n<h4>3.2 GPIO\u521d\u59cb\u5316\u8bbe\u7f6e<\/h4>\n<p>\u914d\u7f6eUSART\u7684\u7b2c\u4e00\u6b65\u662f\u521d\u59cb\u5316\u76f8\u5173\u7684GPIO\u5f15\u811a\u3002\u7531\u4e8eUSART\u5f15\u811a\u662f\u590d\u7528\u529f\u80fd&#xff0c;\u6240\u4ee5\u9700\u8981\u5c06GPIO\u8bbe\u7f6e\u4e3a\u590d\u7528\u63a8\u633d\u8f93\u51fa&#xff08;TX&#xff09;\u548c\u6d6e\u7a7a\u8f93\u5165\u6216\u4e0a\u62c9\u8f93\u5165&#xff08;RX&#xff09;\u3002<\/p>\n<p>\u4ee5\u4e0b\u662fGPIO\u521d\u59cb\u5316\u7684\u4ee3\u7801\u793a\u4f8b&#xff1a;<\/p>\n<p>\/\/ \u4f7f\u80fdGPIO\u65f6\u949f\u548cUSART\u65f6\u949f<br \/>\nRCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_USART1, ENABLE);<\/p>\n<p>GPIO_InitTypeDef GPIO_InitStructure;<br \/>\n\/\/ \u914d\u7f6eTX\u5f15\u811a&#xff08;PA9&#xff09;\u4e3a\u590d\u7528\u63a8\u633d\u8f93\u51fa<br \/>\nGPIO_InitStructure.GPIO_Pin &#061; GPIO_Pin_9;<br \/>\nGPIO_InitStructure.GPIO_Mode &#061; GPIO_Mode_AF_PP;<br \/>\nGPIO_InitStructure.GPIO_Speed &#061; GPIO_Speed_50MHz;<br \/>\nGPIO_Init(GPIOA, &amp;GPIO_InitStructure);<\/p>\n<p>\/\/ \u914d\u7f6eRX\u5f15\u811a&#xff08;PA10&#xff09;\u4e3a\u6d6e\u7a7a\u8f93\u5165<br \/>\nGPIO_InitStructure.GPIO_Pin &#061; GPIO_Pin_10;<br \/>\nGPIO_InitStructure.GPIO_Mode &#061; GPIO_Mode_IN_FLOATING;<br \/>\nGPIO_Init(GPIOA, &amp;GPIO_InitStructure);<\/p>\n<p>\u8fd9\u91cc\u6709\u51e0\u4e2a\u9700\u8981\u6ce8\u610f\u7684\u5730\u65b9&#xff1a;\u4e00\u662f\u8981\u8bb0\u5f97\u4f7f\u80fdGPIO\u7aef\u53e3\u7684\u65f6\u949f\u548cUSART\u7684\u65f6\u949f&#xff1b;\u4e8c\u662fTX\u5f15\u811a\u8981\u8bbe\u7f6e\u4e3a\u590d\u7528\u63a8\u633d\u8f93\u51fa&#xff0c;\u800c\u4e0d\u662f\u666e\u901a\u7684\u63a8\u633d\u8f93\u51fa&#xff1b;\u4e09\u662fRX\u5f15\u811a\u5efa\u8bae\u8bbe\u7f6e\u4e3a\u6d6e\u7a7a\u8f93\u5165\u6216\u4e0a\u62c9\u8f93\u5165&#xff0c;\u800c\u4e0d\u662f\u4e0b\u62c9\u8f93\u5165\u3002<\/p>\n<h4>3.3 USART\u53c2\u6570\u914d\u7f6e<\/h4>\n<p>\u63a5\u4e0b\u6765\u662f\u914d\u7f6eUSART\u7684\u5de5\u4f5c\u53c2\u6570&#xff0c;\u5305\u62ec\u6ce2\u7279\u7387\u3001\u6570\u636e\u4f4d\u957f\u5ea6\u3001\u505c\u6b62\u4f4d\u3001\u6821\u9a8c\u4f4d\u548c\u786c\u4ef6\u6d41\u63a7\u5236\u7b49\u3002STM32\u7684\u6807\u51c6\u5916\u8bbe\u5e93\u63d0\u4f9b\u4e86USART_InitTypeDef\u7ed3\u6784\u4f53\u6765\u7b80\u5316\u914d\u7f6e\u8fc7\u7a0b\u3002<\/p>\n<p>USART_InitTypeDef USART_InitStructure;<br \/>\nUSART_InitStructure.USART_BaudRate &#061; 115200;  \/\/ \u6ce2\u7279\u7387<br \/>\nUSART_InitStructure.USART_WordLength &#061; USART_WordLength_8b;  \/\/ 8\u4f4d\u6570\u636e<br \/>\nUSART_InitStructure.USART_StopBits &#061; USART_StopBits_1;  \/\/ 1\u4f4d\u505c\u6b62\u4f4d<br \/>\nUSART_InitStructure.USART_Parity &#061; USART_Parity_No;  \/\/ \u65e0\u6821\u9a8c<br \/>\nUSART_InitStructure.USART_HardwareFlowControl &#061; USART_HardwareFlowControl_None;  \/\/ \u65e0\u786c\u4ef6\u6d41\u63a7\u5236<br \/>\nUSART_InitStructure.USART_Mode &#061; USART_Mode_Rx | USART_Mode_Tx;  \/\/ \u6536\u53d1\u6a21\u5f0f<\/p>\n<p>USART_Init(USART1, &amp;USART_InitStructure);<br \/>\nUSART_Cmd(USART1, ENABLE);  \/\/ \u4f7f\u80fdUSART<\/p>\n<p>\u6ce2\u7279\u7387\u7684\u9009\u62e9\u9700\u8981\u6839\u636e\u5b9e\u9645\u5e94\u7528\u573a\u666f\u6765\u51b3\u5b9a\u3002115200bps\u662f\u6700\u5e38\u7528\u7684\u901f\u7387&#xff0c;\u4f46\u5bf9\u4e8e\u957f\u8ddd\u79bb\u901a\u4fe1\u6216\u566a\u58f0\u73af\u5883&#xff0c;\u53ef\u80fd\u9700\u8981\u964d\u4f4e\u6ce2\u7279\u7387\u4ee5\u63d0\u9ad8\u53ef\u9760\u6027\u3002\u6211\u66fe\u7ecf\u5728\u4e00\u4e2a\u5de5\u4e1a\u9879\u76ee\u4e2d&#xff0c;\u56e0\u4e3a\u7535\u78c1\u5e72\u6270\u592a\u5f3a&#xff0c;\u4e0d\u5f97\u4e0d\u5c06\u6ce2\u7279\u7387\u4ece115200\u964d\u52309600\u624d\u80fd\u7a33\u5b9a\u901a\u4fe1\u3002<\/p>\n<p>\u6570\u636e\u4f4d\u957f\u5ea6\u901a\u5e38\u9009\u62e98\u4f4d&#xff0c;\u8fd9\u4e0e\u4e00\u4e2a\u5b57\u8282\u7684\u957f\u5ea6\u4e00\u81f4\u3002\u5982\u679c\u9700\u8981\u5947\u5076\u6821\u9a8c&#xff0c;\u53ef\u4ee5\u9009\u62e99\u4f4d\u6570\u636e\u957f\u5ea6&#xff08;8\u4f4d\u6570\u636e&#043;1\u4f4d\u6821\u9a8c\u4f4d&#xff09;\u3002\u505c\u6b62\u4f4d\u901a\u5e38\u9009\u62e91\u4f4d&#xff0c;\u4f46\u5728\u67d0\u4e9b\u7279\u6b8a\u5e94\u7528\u4e2d\u53ef\u80fd\u9700\u8981\u9009\u62e91.5\u4f4d\u62162\u4f4d\u3002<\/p>\n<h3>4. \u4e2d\u65ad\u914d\u7f6e\u4e0e\u6570\u636e\u5904\u7406<\/h3>\n<h4>4.1 NVIC\u4e2d\u65ad\u914d\u7f6e<\/h4>\n<p>\u4e3a\u4e86\u9ad8\u6548\u5904\u7406\u4e32\u53e3\u6570\u636e&#xff0c;\u6211\u4eec\u901a\u5e38\u4f7f\u7528\u4e2d\u65ad\u65b9\u5f0f\u800c\u4e0d\u662f\u8f6e\u8be2\u65b9\u5f0f\u3002STM32\u7684NVIC&#xff08;Nested Vectored Interrupt Controller&#xff09;\u63d0\u4f9b\u4e86\u7075\u6d3b\u7684\u4e2d\u65ad\u4f18\u5148\u7ea7\u7ba1\u7406\u673a\u5236\u3002<\/p>\n<p>\u9996\u5148\u9700\u8981\u914d\u7f6eUSART\u7684\u4e2d\u65ad\u7c7b\u578b\u3002\u6700\u5e38\u7528\u7684\u662f\u63a5\u6536\u4e2d\u65ad&#xff08;USART_IT_RXNE&#xff09;&#xff0c;\u5f53\u63a5\u6536\u5bc4\u5b58\u5668\u975e\u7a7a\u65f6\u89e6\u53d1\u4e2d\u65ad\u3002\u6b64\u5916&#xff0c;\u8fd8\u53ef\u4ee5\u4f7f\u80fd\u53d1\u9001\u5b8c\u6210\u4e2d\u65ad&#xff08;USART_IT_TC&#xff09;\u6216\u53d1\u9001\u5bc4\u5b58\u5668\u7a7a\u4e2d\u65ad&#xff08;USART_IT_TXE&#xff09;\u3002<\/p>\n<p>\/\/ \u4f7f\u80fd\u63a5\u6536\u4e2d\u65ad<br \/>\nUSART_ITConfig(USART1, USART_IT_RXNE, ENABLE);<\/p>\n<p>\/\/ \u914d\u7f6eNVIC<br \/>\nNVIC_InitTypeDef NVIC_InitStructure;<br \/>\nNVIC_InitStructure.NVIC_IRQChannel &#061; USART1_IRQn;<br \/>\nNVIC_InitStructure.NVIC_IRQChannelPreemptionPriority &#061; 1;<br \/>\nNVIC_InitStructure.NVIC_IRQChannelSubPriority &#061; 1;<br \/>\nNVIC_InitStructure.NVIC_IRQChannelCmd &#061; ENABLE;<br \/>\nNVIC_Init(&amp;NVIC_InitStructure);<\/p>\n<p>\u5728\u914d\u7f6e\u4e2d\u65ad\u4f18\u5148\u7ea7\u65f6&#xff0c;\u9700\u8981\u6839\u636e\u7cfb\u7edf\u4e2d\u5176\u4ed6\u4e2d\u65ad\u7684\u91cd\u8981\u6027\u6765\u5408\u7406\u5206\u914d\u4f18\u5148\u7ea7\u3002\u5982\u679c\u4e32\u53e3\u901a\u4fe1\u7684\u5b9e\u65f6\u6027\u8981\u6c42\u4e0d\u9ad8&#xff0c;\u53ef\u4ee5\u8bbe\u7f6e\u8f83\u4f4e\u7684\u4f18\u5148\u7ea7&#xff0c;\u907f\u514d\u5f71\u54cd\u66f4\u91cd\u8981\u7684\u4efb\u52a1\u3002<\/p>\n<h4>4.2 \u4e2d\u65ad\u670d\u52a1\u51fd\u6570\u7f16\u5199<\/h4>\n<p>\u4e2d\u65ad\u670d\u52a1\u51fd\u6570\u662f\u5904\u7406\u4e32\u53e3\u6570\u636e\u7684\u6838\u5fc3\u3002\u5f53\u89e6\u53d1\u4e2d\u65ad\u65f6&#xff0c;\u7a0b\u5e8f\u4f1a\u8df3\u8f6c\u5230\u4e2d\u65ad\u670d\u52a1\u51fd\u6570\u6267\u884c\u76f8\u5e94\u7684\u5904\u7406\u903b\u8f91\u3002<\/p>\n<p>void USART1_IRQHandler(void)<br \/>\n{<br \/>\n    if(USART_GetITStatus(USART1, USART_IT_RXNE) !&#061; RESET)<br \/>\n    {<br \/>\n        \/\/ \u8bfb\u53d6\u63a5\u6536\u5230\u7684\u6570\u636e<br \/>\n        uint8_t receivedData &#061; USART_ReceiveData(USART1);<\/p>\n<p>        \/\/ \u5904\u7406\u6570\u636e&#xff0c;\u6bd4\u5982\u5b58\u5165\u7f13\u51b2\u533a<br \/>\n        \/\/ &#8230;<\/p>\n<p>        \/\/ \u53ef\u9009&#xff1a;\u56de\u663e\u6570\u636e<br \/>\n        USART_SendData(USART1, receivedData);<br \/>\n    }<\/p>\n<p>    \/\/ \u6e05\u9664\u4e2d\u65ad\u6807\u5fd7\u4f4d<br \/>\n    USART_ClearITPendingBit(USART1, USART_IT_RXNE);<br \/>\n}<\/p>\n<p>\u5728\u4e2d\u65ad\u670d\u52a1\u51fd\u6570\u4e2d&#xff0c;\u9996\u5148\u8981\u68c0\u67e5\u662f\u54ea\u79cd\u4e2d\u65ad\u89e6\u53d1\u7684&#xff0c;\u7136\u540e\u8fdb\u884c\u76f8\u5e94\u7684\u5904\u7406\u3002\u5904\u7406\u5b8c\u6210\u540e&#xff0c;\u4e00\u5b9a\u8981\u6e05\u9664\u4e2d\u65ad\u6807\u5fd7\u4f4d&#xff0c;\u5426\u5219\u4f1a\u8fde\u7eed\u8fdb\u5165\u4e2d\u65ad\u3002<\/p>\n<p>\u5bf9\u4e8e\u6570\u636e\u63a5\u6536&#xff0c;\u6211\u5efa\u8bae\u4f7f\u7528\u73af\u5f62\u7f13\u51b2\u533a&#xff08;ring buffer&#xff09;\u6765\u5b58\u50a8\u6570\u636e\u3002\u56e0\u4e3a\u4e2d\u65ad\u53ef\u80fd\u5728\u4efb\u4f55\u65f6\u5019\u53d1\u751f&#xff0c;\u800c\u4e3b\u7a0b\u5e8f\u53ef\u80fd\u6b63\u5728\u5904\u7406\u5176\u4ed6\u4efb\u52a1\u3002\u4f7f\u7528\u7f13\u51b2\u533a\u53ef\u4ee5\u89e3\u8026\u6570\u636e\u63a5\u6536\u548c\u6570\u636e\u5904\u7406&#xff0c;\u63d0\u9ad8\u7cfb\u7edf\u7684\u53ef\u9760\u6027\u3002<\/p>\n<h4>4.3 \u6570\u636e\u53d1\u9001\u4e0e\u63a5\u6536<\/h4>\n<p>\u6570\u636e\u53d1\u9001\u76f8\u5bf9\u7b80\u5355&#xff0c;\u53ea\u9700\u8981\u5c06\u6570\u636e\u5199\u5165USART\u7684\u6570\u636e\u5bc4\u5b58\u5668&#xff08;DR&#xff09;\u5373\u53ef\u3002\u4f46\u9700\u8981\u6ce8\u610f\u7b49\u5f85\u53d1\u9001\u5b8c\u6210\u6216\u53d1\u9001\u5bc4\u5b58\u5668\u4e3a\u7a7a&#xff0c;\u5426\u5219\u53ef\u80fd\u4f1a\u8986\u76d6\u4e4b\u524d\u7684\u6570\u636e\u3002<\/p>\n<p>void USART_SendByte(USART_TypeDef* USARTx, uint8_t data)<br \/>\n{<br \/>\n    USART_SendData(USARTx, data);<br \/>\n    \/\/ \u7b49\u5f85\u53d1\u9001\u5b8c\u6210<br \/>\n    while(USART_GetFlagStatus(USARTx, USART_FLAG_TC) &#061;&#061; RESET);<br \/>\n}<\/p>\n<p>void USART_SendString(USART_TypeDef* USARTx, const char* str)<br \/>\n{<br \/>\n    while(*str)<br \/>\n    {<br \/>\n        USART_SendByte(USARTx, *str&#043;&#043;);<br \/>\n    }<br \/>\n}<\/p>\n<p>\u5bf9\u4e8e\u5927\u91cf\u6570\u636e\u7684\u53d1\u9001&#xff0c;\u5efa\u8bae\u4f7f\u7528DMA&#xff08;Direct Memory Access&#xff09;\u65b9\u5f0f&#xff0c;\u8fd9\u6837\u53ef\u4ee5\u89e3\u653eCPU&#xff0c;\u63d0\u9ad8\u7cfb\u7edf\u6548\u7387\u3002STM32\u7684USART\u652f\u6301DMA\u4f20\u8f93&#xff0c;\u53ef\u4ee5\u901a\u8fc7\u914d\u7f6e\u5b9e\u73b0\u81ea\u52a8\u7684\u6570\u636e\u53d1\u9001\u548c\u63a5\u6536\u3002<\/p>\n<p>\u5728\u6570\u636e\u63a5\u6536\u65b9\u9762&#xff0c;\u9664\u4e86\u4e2d\u65ad\u65b9\u5f0f&#xff0c;\u8fd8\u53ef\u4ee5\u4f7f\u7528\u8f6e\u8be2\u65b9\u5f0f\u3002\u4f46\u8f6e\u8be2\u65b9\u5f0f\u4f1a\u5360\u7528CPU\u8d44\u6e90&#xff0c;\u4e00\u822c\u53ea\u7528\u4e8e\u7b80\u5355\u7684\u5e94\u7528\u6216\u8c03\u8bd5\u76ee\u7684\u3002<\/p>\n<h3>5. \u5b9e\u6218\u5e94\u7528\u4e0e\u8c03\u8bd5\u6280\u5de7<\/h3>\n<h4>5.1 \u5e38\u7528\u8c03\u8bd5\u5de5\u5177\u4e0e\u65b9\u6cd5<\/h4>\n<p>\u4e32\u53e3\u8c03\u8bd5\u6700\u5e38\u7528\u7684\u5de5\u5177\u662f\u4e32\u53e3\u8c03\u8bd5\u52a9\u624b&#xff0c;\u5982SecureCRT\u3001Putty\u3001\u6216\u8005\u5404\u79cd\u5382\u5bb6\u63d0\u4f9b\u7684\u8c03\u8bd5\u5de5\u5177\u3002\u8fd9\u4e9b\u5de5\u5177\u53ef\u4ee5\u663e\u793a\u63a5\u6536\u5230\u7684\u6570\u636e&#xff0c;\u4e5f\u53ef\u4ee5\u53d1\u9001\u6570\u636e\u5230\u5355\u7247\u673a\u3002<\/p>\n<p>\u5728\u8c03\u8bd5\u65f6&#xff0c;\u6211\u4e60\u60ef\u9996\u5148\u6d4b\u8bd5\u56de\u73af&#xff08;loopback&#xff09;\u529f\u80fd&#xff1a;\u5c06STM32\u7684TX\u548cRX\u5f15\u811a\u77ed\u63a5&#xff0c;\u7136\u540e\u53d1\u9001\u6570\u636e&#xff0c;\u770b\u662f\u5426\u80fd\u6b63\u786e\u63a5\u6536\u3002\u8fd9\u6837\u53ef\u4ee5\u6392\u9664\u5916\u90e8\u7535\u8def\u7684\u95ee\u9898&#xff0c;\u786e\u8ba4STM32\u672c\u8eab\u7684\u4e32\u53e3\u529f\u80fd\u6b63\u5e38\u3002<\/p>\n<p>\u5982\u679c\u901a\u4fe1\u4e0d\u6b63\u5e38&#xff0c;\u53ef\u4ee5\u5148\u7528\u793a\u6ce2\u5668\u6216\u903b\u8f91\u5206\u6790\u4eea\u68c0\u67e5\u6ce2\u5f62\u3002\u6b63\u5e38\u7684\u4e32\u53e3\u6ce2\u5f62\u5e94\u8be5\u6709\u6e05\u6670\u7684\u8d77\u59cb\u4f4d\u3001\u6570\u636e\u4f4d\u548c\u505c\u6b62\u4f4d\u3002\u901a\u8fc7\u6d4b\u91cf\u4f4d\u65f6\u95f4&#xff0c;\u53ef\u4ee5\u9a8c\u8bc1\u6ce2\u7279\u7387\u662f\u5426\u6b63\u786e\u3002\u6211\u66fe\u7ecf\u5c31\u7528\u8fd9\u79cd\u65b9\u6cd5\u53d1\u73b0\u8fc7\u65f6\u949f\u914d\u7f6e\u9519\u8bef\u5bfc\u81f4\u7684\u6ce2\u7279\u7387\u504f\u5dee\u95ee\u9898\u3002<\/p>\n<h4>5.2 \u5e38\u89c1\u95ee\u9898\u4e0e\u89e3\u51b3\u65b9\u6848<\/h4>\n<p>\u5728\u4e32\u53e3\u901a\u4fe1\u4e2d&#xff0c;\u6700\u5e38\u89c1\u7684\u95ee\u9898\u662f\u6570\u636e\u4e71\u7801&#xff0c;\u8fd9\u901a\u5e38\u662f\u6ce2\u7279\u7387\u4e0d\u5339\u914d\u5bfc\u81f4\u7684\u3002\u786e\u4fdd\u53d1\u9001\u548c\u63a5\u6536\u65b9\u7684\u6ce2\u7279\u7387\u3001\u6570\u636e\u4f4d\u3001\u505c\u6b62\u4f4d\u548c\u6821\u9a8c\u4f4d\u8bbe\u7f6e\u5b8c\u5168\u4e00\u81f4\u3002<\/p>\n<p>\u53e6\u4e00\u4e2a\u5e38\u89c1\u95ee\u9898\u662f\u6570\u636e\u4e22\u5931&#xff0c;\u7279\u522b\u662f\u5728\u9ad8\u901f\u4f20\u8f93\u65f6\u3002\u8fd9\u53ef\u80fd\u662f\u7531\u4e8e\u4e2d\u65ad\u4f18\u5148\u7ea7\u8bbe\u7f6e\u4e0d\u5408\u7406&#xff0c;\u5bfc\u81f4\u672a\u80fd\u53ca\u65f6\u5904\u7406\u63a5\u6536\u5230\u7684\u6570\u636e\u3002\u89e3\u51b3\u65b9\u6cd5\u5305\u62ec\u4f18\u5316\u4e2d\u65ad\u4f18\u5148\u7ea7\u3001\u4f7f\u7528DMA\u4f20\u8f93\u3001\u6216\u8005\u589e\u52a0\u786c\u4ef6\u7f13\u51b2\u533a\u3002<\/p>\n<p>\u7535\u78c1\u5e72\u6270\u4e5f\u662f\u5bfc\u81f4\u901a\u4fe1\u9519\u8bef\u7684\u91cd\u8981\u539f\u56e0\u3002\u5728\u5de5\u4e1a\u73af\u5883\u4e2d&#xff0c;\u53ef\u4ee5\u4f7f\u7528\u5c4f\u853d\u7ebf\u7f06\u3001\u589e\u52a0\u6ee4\u6ce2\u7535\u5bb9\u3001\u6216\u8005\u964d\u4f4e\u6ce2\u7279\u7387\u6765\u63d0\u9ad8\u6297\u5e72\u6270\u80fd\u529b\u3002\u6211\u5728\u4e00\u4e2a\u9879\u76ee\u4e2d\u5c31\u66fe\u56e0\u4e3a\u7535\u673a\u5e72\u6270\u5bfc\u81f4\u4e32\u53e3\u901a\u4fe1\u9519\u8bef&#xff0c;\u540e\u6765\u5728\u7ebf\u4e0a\u52a0\u4e86\u78c1\u73af\u624d\u89e3\u51b3\u95ee\u9898\u3002<\/p>\n<h4>5.3 \u6027\u80fd\u4f18\u5316\u5efa\u8bae<\/h4>\n<p>\u5bf9\u4e8e\u9700\u8981\u9ad8\u901f\u4f20\u8f93\u7684\u5e94\u7528&#xff0c;\u53ef\u4ee5\u8003\u8651\u4ee5\u4e0b\u4f18\u5316\u63aa\u65bd&#xff1a;\u4f7f\u7528\u66f4\u9ad8\u7684\u7cfb\u7edf\u65f6\u949f\u4ee5\u63d0\u9ad8\u6ce2\u7279\u7387\u7cbe\u5ea6&#xff1b;\u4f7f\u7528DMA\u51cf\u5c11CPU\u5f00\u9500&#xff1b;\u4f7f\u7528\u786c\u4ef6\u6d41\u63a7\u5236&#xff08;RTS\/CTS&#xff09;\u907f\u514d\u6570\u636e\u4e22\u5931\u3002<\/p>\n<p>\u5bf9\u4e8e\u4f4e\u529f\u8017\u5e94\u7528&#xff0c;\u53ef\u4ee5\u5408\u7406\u7ba1\u7406USART\u7684\u65f6\u949f\u5f00\u5173&#xff0c;\u5728\u4e0d\u9700\u8981\u901a\u4fe1\u65f6\u5173\u95ed\u65f6\u949f\u4ee5\u8282\u7701\u529f\u8017\u3002STM32\u8fd8\u652f\u6301\u5728\u505c\u6b62\u6a21\u5f0f\u4e0b\u901a\u8fc7\u4e32\u53e3\u5524\u9192&#xff0c;\u8fd9\u5bf9\u4e8e\u7535\u6c60\u4f9b\u7535\u7684\u8bbe\u5907\u5f88\u6709\u7528\u3002<\/p>\n<p>\u4ee3\u7801\u4f18\u5316\u65b9\u9762&#xff0c;\u907f\u514d\u5728\u4e2d\u65ad\u670d\u52a1\u51fd\u6570\u4e2d\u6267\u884c\u8017\u65f6\u64cd\u4f5c&#xff1b;\u4f7f\u7528\u5185\u5b58\u6c60\u7ba1\u7406\u6570\u636e\u7f13\u51b2\u533a&#xff1b;\u5bf9\u4e8e\u9891\u7e41\u53d1\u9001\u7684\u6570\u636e&#xff0c;\u53ef\u4ee5\u9884\u5148\u683c\u5f0f\u5316\u597d\u5b58\u50a8\u5728\u7f13\u51b2\u533a\u4e2d\u3002<\/p>\n<p>\u5728\u5b9e\u9645\u9879\u76ee\u4e2d&#xff0c;\u6211\u8fd8\u4f1a\u6dfb\u52a0\u901a\u4fe1\u534f\u8bae\u5c42&#xff0c;\u6bd4\u5982\u7b80\u5355\u7684\u5e27\u5934\u5e27\u5c3e\u6821\u9a8c&#xff0c;\u6216\u8005\u66f4\u590d\u6742\u7684Modbus\u534f\u8bae\u3002\u8fd9\u6837\u53ef\u4ee5\u63d0\u9ad8\u901a\u4fe1\u7684\u53ef\u9760\u6027&#xff0c;\u4e5f\u4fbf\u4e8e\u4e0e\u5176\u4ed6\u8bbe\u5907\u5bf9\u63a5\u3002<\/p>\n<p>\u8bb0\u5f97\u5728\u6b63\u5f0f\u53d1\u5e03\u7a0b\u5e8f\u65f6&#xff0c;\u79fb\u9664\u6216\u7981\u7528\u8c03\u8bd5\u8f93\u51fa\u4ee3\u7801&#xff0c;\u4ee5\u51cf\u5c11\u4e0d\u5fc5\u8981\u7684\u5f00\u9500\u548c\u63d0\u9ad8\u5b89\u5168\u6027\u3002\u53ef\u4ee5\u901a\u8fc7\u5b8f\u5b9a\u4e49\u6765\u63a7\u5236\u8c03\u8bd5\u8f93\u51fa\u7684\u5f00\u5173&#xff0c;\u8fd9\u6837\u5728\u9700\u8981\u65f6\u53ef\u4ee5\u5feb\u901f\u542f\u7528\u8c03\u8bd5\u529f\u80fd\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. USART\u4e32\u53e3\u901a\u4fe1\u57fa\u7840\u6982\u5ff5<br \/>\n\u5927\u5bb6\u597d&#xff0c;\u6211\u662f\u6c5f\u79d1\u5927\u7684\u8001\u5b66\u957f&#xff0c;\u4eca\u5929\u6765\u804a\u804aUSART\u4e32\u53e3\u901a\u4fe1\u534f\u8bae\u548cSTM32\u7684\u5b9e\u6218\u914d\u7f6e\u3002\u5982\u679c\u4f60\u521a\u5f00\u59cb\u63a5\u89e6\u5d4c\u5165\u5f0f\u5f00\u53d1&#xff0c;\u4e32\u53e3\u901a\u4fe1\u7edd\u5bf9\u662f\u4f60\u7b2c\u4e00\u4e2a\u8981\u638c\u63e1\u7684\u901a\u4fe1\u534f\u8bae&#xff0c;\u56e0\u4e3a\u5b83\u7b80\u5355\u5b9e\u7528&#xff0c;\u51e0\u4e4e\u6240\u6709\u7684\u5fae\u63a7\u5236\u5668\u90fd\u652f\u6301\u8fd9\u4e2a\u529f\u80fd\u3002<br \/>\nUSART\u7684\u5168\u79f0\u662fUniversal Synchronous\/Asynchronous Receiver\/Transmitter&#xff0c;\u4e2d\u6587\u53eb\u901a\u7528\u540c\u6b65\u5f02\u6b65\u6536\u53d1\u5668\u3002\u7b80<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[8281,7701,217,2896],"topic":[],"class_list":["post-76698","post","type-post","status-publish","format-standard","hentry","category-server","tag-usart","tag-7701","tag-stm32","tag-2896"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u6c5f\u79d1\u5927\u7b14\u8bb0\u2014USART\u4e32\u53e3\u901a\u4fe1\u534f\u8bae\u4e0eSTM32\u5b9e\u6218\u914d\u7f6e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/76698.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u6c5f\u79d1\u5927\u7b14\u8bb0\u2014USART\u4e32\u53e3\u901a\u4fe1\u534f\u8bae\u4e0eSTM32\u5b9e\u6218\u914d\u7f6e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"1. USART\u4e32\u53e3\u901a\u4fe1\u57fa\u7840\u6982\u5ff5 \u5927\u5bb6\u597d&#xff0c;\u6211\u662f\u6c5f\u79d1\u5927\u7684\u8001\u5b66\u957f&#xff0c;\u4eca\u5929\u6765\u804a\u804aUSART\u4e32\u53e3\u901a\u4fe1\u534f\u8bae\u548cSTM32\u7684\u5b9e\u6218\u914d\u7f6e\u3002\u5982\u679c\u4f60\u521a\u5f00\u59cb\u63a5\u89e6\u5d4c\u5165\u5f0f\u5f00\u53d1&#xff0c;\u4e32\u53e3\u901a\u4fe1\u7edd\u5bf9\u662f\u4f60\u7b2c\u4e00\u4e2a\u8981\u638c\u63e1\u7684\u901a\u4fe1\u534f\u8bae&#xff0c;\u56e0\u4e3a\u5b83\u7b80\u5355\u5b9e\u7528&#xff0c;\u51e0\u4e4e\u6240\u6709\u7684\u5fae\u63a7\u5236\u5668\u90fd\u652f\u6301\u8fd9\u4e2a\u529f\u80fd\u3002 USART\u7684\u5168\u79f0\u662fUniversal Synchronous\/Asynchronous Receiver\/Transmitter&#xff0c;\u4e2d\u6587\u53eb\u901a\u7528\u540c\u6b65\u5f02\u6b65\u6536\u53d1\u5668\u3002\u7b80\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/76698.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-02-22T20:17:19+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/76698.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/76698.html\",\"name\":\"\u6c5f\u79d1\u5927\u7b14\u8bb0\u2014USART\u4e32\u53e3\u901a\u4fe1\u534f\u8bae\u4e0eSTM32\u5b9e\u6218\u914d\u7f6e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-02-22T20:17:19+00:00\",\"dateModified\":\"2026-02-22T20:17:19+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/76698.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/76698.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/76698.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u6c5f\u79d1\u5927\u7b14\u8bb0\u2014USART\u4e32\u53e3\u901a\u4fe1\u534f\u8bae\u4e0eSTM32\u5b9e\u6218\u914d\u7f6e\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u6c5f\u79d1\u5927\u7b14\u8bb0\u2014USART\u4e32\u53e3\u901a\u4fe1\u534f\u8bae\u4e0eSTM32\u5b9e\u6218\u914d\u7f6e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/76698.html","og_locale":"zh_CN","og_type":"article","og_title":"\u6c5f\u79d1\u5927\u7b14\u8bb0\u2014USART\u4e32\u53e3\u901a\u4fe1\u534f\u8bae\u4e0eSTM32\u5b9e\u6218\u914d\u7f6e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"1. USART\u4e32\u53e3\u901a\u4fe1\u57fa\u7840\u6982\u5ff5 \u5927\u5bb6\u597d&#xff0c;\u6211\u662f\u6c5f\u79d1\u5927\u7684\u8001\u5b66\u957f&#xff0c;\u4eca\u5929\u6765\u804a\u804aUSART\u4e32\u53e3\u901a\u4fe1\u534f\u8bae\u548cSTM32\u7684\u5b9e\u6218\u914d\u7f6e\u3002\u5982\u679c\u4f60\u521a\u5f00\u59cb\u63a5\u89e6\u5d4c\u5165\u5f0f\u5f00\u53d1&#xff0c;\u4e32\u53e3\u901a\u4fe1\u7edd\u5bf9\u662f\u4f60\u7b2c\u4e00\u4e2a\u8981\u638c\u63e1\u7684\u901a\u4fe1\u534f\u8bae&#xff0c;\u56e0\u4e3a\u5b83\u7b80\u5355\u5b9e\u7528&#xff0c;\u51e0\u4e4e\u6240\u6709\u7684\u5fae\u63a7\u5236\u5668\u90fd\u652f\u6301\u8fd9\u4e2a\u529f\u80fd\u3002 USART\u7684\u5168\u79f0\u662fUniversal Synchronous\/Asynchronous Receiver\/Transmitter&#xff0c;\u4e2d\u6587\u53eb\u901a\u7528\u540c\u6b65\u5f02\u6b65\u6536\u53d1\u5668\u3002\u7b80","og_url":"https:\/\/www.wsisp.com\/helps\/76698.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-02-22T20:17:19+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/76698.html","url":"https:\/\/www.wsisp.com\/helps\/76698.html","name":"\u6c5f\u79d1\u5927\u7b14\u8bb0\u2014USART\u4e32\u53e3\u901a\u4fe1\u534f\u8bae\u4e0eSTM32\u5b9e\u6218\u914d\u7f6e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-02-22T20:17:19+00:00","dateModified":"2026-02-22T20:17:19+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/76698.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/76698.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/76698.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u6c5f\u79d1\u5927\u7b14\u8bb0\u2014USART\u4e32\u53e3\u901a\u4fe1\u534f\u8bae\u4e0eSTM32\u5b9e\u6218\u914d\u7f6e"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/76698","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=76698"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/76698\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=76698"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=76698"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=76698"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=76698"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}