{"id":77461,"date":"2023-12-31T22:57:25","date_gmt":"2023-12-31T14:57:25","guid":{"rendered":"\/\/www.viralrail.com\/?p=77461"},"modified":"2023-12-31T22:57:25","modified_gmt":"2023-12-31T14:57:25","slug":"scsh","status":"publish","type":"post","link":"\/\/www.viralrail.com\/blog\/77461.html","title":{"rendered":"STM32 UART\u521d\u59cb\u5316"},"content":{"rendered":"

  STM32 UART\u521d\u59cb\u5316\u662f\u5d4c\u5165\u5f0f\u7cfb\u7edf\u5f00\u53d1\u4e2d\u7684\u91cd\u8981\u6b65\u9aa4\uff0c\u901a\u8fc7\u6b63\u786e\u914d\u7f6e\u4e32\u884c\u901a\u4fe1\u63a5\u53e3\uff0c\u53ef\u4ee5\u5b9e\u73b0\u4e0e\u5916\u90e8\u8bbe\u5907\u7684\u7a33\u5b9a\u901a\u4fe1\uff0c\u4e3a\u5d4c\u5165\u5f0f\u7cfb\u7edf\u7684\u529f\u80fd\u63d0\u4f9b\u57fa\u7840\u652f\u6301\u3002<\/p>\n

UART\u4ecb\u7ecd<\/h2>\n

  UART\uff08Universal Asynchronous Receiver\/Transmitter\uff0c\u901a\u7528\u5f02\u6b65\u6536\u53d1\u5668\uff09\u662f\u4e00\u79cd\u5e38\u89c1\u7684\u4e32\u884c\u901a\u4fe1\u63a5\u53e3\uff0c\u7528\u4e8e\u5728\u5d4c\u5165\u5f0f\u7cfb\u7edf\u4e2d\u8fdb\u884c\u7b80\u5355\u3001\u5feb\u901f\u7684\u6570\u636e\u4f20\u8f93\u3002\u5b83\u901a\u8fc7\u53d1\u9001\u548c\u63a5\u6536\u6570\u636e\u4f4d\u6765\u5b9e\u73b0\u901a\u4fe1\uff0c\u5177\u6709\u5e7f\u6cdb\u7684\u5e94\u7528\u9886\u57df\u3002<\/p>\n

  UART\u5de5\u4f5c\u539f\u7406<\/h3>\n

  UART\u5de5\u4f5c\u4ee5\u4e00\u4e2a\u56fa\u5b9a\u7684\u6ce2\u7279\u7387\u8fdb\u884c\uff0c\u53d1\u9001\u7aef\u548c\u63a5\u6536\u7aef\u9700\u8981\u8bbe\u7f6e\u76f8\u540c\u7684\u6ce2\u7279\u7387\u624d\u80fd\u6b63\u786e\u8fdb\u884c\u901a\u4fe1\u3002\u6570\u636e\u4ee5\u5b57\u8282\u7684\u5f62\u5f0f\u53d1\u9001\uff0c\u5305\u62ec\u8d77\u59cb\u4f4d\u3001\u6570\u636e\u4f4d\u3001\u5947\u5076\u6821\u9a8c<\/a>\u4f4d\u548c\u505c\u6b62\u4f4d\u3002<\/p>\n

  STM32\u4e2d\u7684UART<\/h3>\n

  \u5728STM32\u7cfb\u5217\u5fae\u63a7\u5236\u5668\u4e2d\uff0cUART\u662f\u4e00\u79cd\u5e38\u89c1\u7684\u5916\u8bbe\uff0c\u53ef\u4ee5\u901a\u8fc7\u5bc4\u5b58\u5668\u914d\u7f6e\u5b9e\u73b0\u521d\u59cb\u5316\u8bbe\u7f6e\u3002\u4f7f\u7528STM32 HAL\u5e93\u53ef\u4ee5\u66f4\u65b9\u4fbf\u5730\u8fdb\u884c\u521d\u59cb\u5316\u914d\u7f6e\u3002<\/p>\n

STM32 UART\u521d\u59cb\u5316<\/h2>\n

  UART\u521d\u59cb\u5316\u6b65\u9aa4<\/h3>\n

  \u5728STM32<\/a>\u4e2d\u521d\u59cb\u5316UART\u901a\u5e38\u5305\u62ec\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n

   1. \u8bbe\u7f6eGPIO<\/a>\u5f15\u811a\u7684\u590d\u7528\u6a21\u5f0f\u548c\u901f\u5ea6<\/p>\n

   2. \u914d\u7f6eUART\u7684\u57fa\u672c\u53c2\u6570\uff0c\u5982\u6ce2\u7279\u7387\u3001\u6570\u636e\u4f4d\u3001\u505c\u6b62\u4f4d\u548c\u6821\u9a8c\u4f4d<\/p>\n

   3. \u542f\u7528UART\u5916\u8bbe\u548c\u4e2d\u65ad\uff08\u53ef\u9009\uff09<\/p>\n

   4. \u6700\u540e\u6fc0\u6d3bUART<\/p>\n

  C\u4ee3\u7801\u793a\u4f8b<\/h3>\n
 \/\/ \u4f7f\u7528STM32 HAL\u5e93\u8fdb\u884cUART\u521d\u59cb\u5316\u793a\u4f8b<\/p> UART_HandleTypeDef huart;<\/p> huart.Instance = USARTx;<\/p> huart.Init.BaudRate = 9600;<\/p> huart.Init.WordLength = UART_WORDLENGTH_8B;<\/p> huart.Init.StopBits = UART_STOPBITS_1;<\/p> huart.Init.Parity = UART_PARITY_NONE;<\/p> huart.Init.Mode = UART_MODE_TX_RX;<\/p> huart.Init.HwFlowCtl = UART_HWCONTROL_NONE;<\/p> HAL_UART_Init(&huart);<\/p><\/code><\/pre>\n

\u603b\u7ed3<\/h2>\n

  \u901a\u8fc7\u672c\u6587\u4ecb\u7ecd\uff0c\u6211\u4eec\u4e86\u89e3\u4e86UART\u7684\u57fa\u672c\u539f\u7406\u548cSTM32\u4e2d\u7684UART\u521d\u59cb\u5316\u6b65\u9aa4\u3002<\/strong>\u6b63\u786e\u5730\u914d\u7f6e\u548c\u521d\u59cb\u5316UART\u53ef\u4ee5\u4fdd\u8bc1\u5d4c\u5165\u5f0f\u7cfb\u7edf\u4e0e\u5916\u90e8\u8bbe\u5907\u4e4b\u95f4\u7a33\u5b9a\u7684\u6570\u636e\u4ea4\u6362\uff0c\u4e3a\u5b9e\u9645\u5e94\u7528\u63d0\u4f9b\u4e86\u575a\u5b9e\u7684\u57fa\u7840\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

STM32UART\u521d\u59cb\u5316\u662f\u5d4c\u5165\u5f0f\u7cfb\u7edf\u5f00\u53d1\u4e2d\u7684\u91cd\u8981\u6b65\u9aa4\uff0c\u901a\u8fc7\u6b63\u786e\u914d\u7f6e\u4e32\u884c\u901a\u4fe1\u63a5\u53e3\uff0c\u53ef\u4ee5\u5b9e\u73b0\u4e0e\u5916\u90e8\u8bbe\u5907\u7684\u7a33\u5b9a\u901a\u4fe1\uff0c\u4e3a\u5d4c\u5165\u5f0f\u7cfb\u7edf\u7684\u529f\u80fd\u63d0\u4f9b\u57fa\u7840\u652f\u6301\u3002UART\u4ecb\u7ecdUAR<\/p>\n","protected":false},"author":1,"featured_media":64183,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-global-header-display":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","footnotes":""},"categories":[36],"tags":[145],"class_list":["post-77461","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-uart"],"_links":{"self":[{"href":"\/\/www.viralrail.com\/wp-json\/wp\/v2\/posts\/77461"}],"collection":[{"href":"\/\/www.viralrail.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"\/\/www.viralrail.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"\/\/www.viralrail.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"\/\/www.viralrail.com\/wp-json\/wp\/v2\/comments?post=77461"}],"version-history":[{"count":0,"href":"\/\/www.viralrail.com\/wp-json\/wp\/v2\/posts\/77461\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"\/\/www.viralrail.com\/wp-json\/wp\/v2\/media\/64183"}],"wp:attachment":[{"href":"\/\/www.viralrail.com\/wp-json\/wp\/v2\/media?parent=77461"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"\/\/www.viralrail.com\/wp-json\/wp\/v2\/categories?post=77461"},{"taxonomy":"post_tag","embeddable":true,"href":"\/\/www.viralrail.com\/wp-json\/wp\/v2\/tags?post=77461"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}