{"id":39100,"date":"2023-10-03T09:54:28","date_gmt":"2023-10-03T01:54:28","guid":{"rendered":"https:\/\/www.techphant.cn\/?p=39100"},"modified":"2023-10-03T09:54:28","modified_gmt":"2023-10-03T01:54:28","slug":"sduhu","status":"publish","type":"post","link":"https:\/\/www.techphant.cn\/blog\/39100.html","title":{"rendered":"STM32\u7684UART\u548cUSART"},"content":{"rendered":"
STM32\u7684UART\u548cUSART\u662f\u4e00\u79cd\u9ad8\u6027\u80fd\u7684\u901a\u4fe1\u63a5\u53e3\uff0c\u5b83\u88ab\u5e7f\u6cdb\u5e94\u7528\u4e8e\u5404\u79cd\u8bbe\u5907\u4e4b\u95f4\u7684\u6570\u636e\u4f20\u8f93\u3002\u672c\u6587\u5c06\u4ecb\u7ecdSTM32\u7684UART\u548cUSART\uff0c\u91cd\u70b9\u8bb2\u89e3\u5b83\u4eec\u7684\u7279\u6027\u3001\u5de5\u4f5c\u539f\u7406\u3001\u5e94\u7528\u573a\u666f\uff0c\u5e76\u7ed9\u51fa\u76f8\u5173\u7684\u793a\u4f8b\u4ee3\u7801\u3002<\/p>\n
UART\uff08Universal Asynchronous Receiver\/Transmitter\uff09\u662f\u4e00\u79cd\u5f02\u6b65\u4e32\u884c\u901a\u4fe1\u63a5\u53e3\uff0c\u5b83\u53ef\u4ee5\u5b9e\u73b0\u4e24\u4e2a\u8bbe\u5907\u4e4b\u95f4\u7684\u6570\u636e\u4f20\u8f93\u3002\u5b83\u901a\u8fc7\u53d1\u9001\u548c\u63a5\u6536\u4e24\u4e2a\u4fe1\u53f7\u6765\u5b8c\u6210\u6570\u636e\u4f20\u8f93\uff0c\u53d1\u9001\u4fe1\u53f7\u7531TX\uff08Transmit\uff09\u7ebf\u8d1f\u8d23\uff0c\u63a5\u6536\u4fe1\u53f7\u7531RX\uff08Receive\uff09\u7ebf\u8d1f\u8d23\u3002UART\u7684\u7279\u70b9\u662f\u7b80\u5355\u6613\u7528\uff0c\u5b83\u53ef\u4ee5\u652f\u6301\u540c\u6b65\u548c\u5f02\u6b65\u4f20\u8f93\uff0c\u5e76\u4e14\u53ef\u4ee5\u652f\u6301\u591a\u79cd\u6570\u636e\u4f20\u8f93\u534f\u8bae\uff0c\u5982RS-232\u3001RS-485\u7b49\u3002<\/p>\n
UART\u53ef\u4ee5\u5e94\u7528\u4e8e\u5404\u79cd\u8bbe\u5907\u4e4b\u95f4\u7684\u6570\u636e\u4f20\u8f93\uff0c\u5982\u7535\u8111\u4e0e\u8bbe\u5907\u4e4b\u95f4\u7684\u6570\u636e\u4f20\u8f93\uff0c\u8bbe\u5907\u4e4b\u95f4\u7684\u6570\u636e\u4f20\u8f93\u7b49\u3002\u5b83\u53ef\u4ee5\u7528\u4e8e\u5b9e\u73b0\u5404\u79cd\u590d\u6742\u7684\u6570\u636e\u4f20\u8f93\uff0c\u5982\u8fdc\u7a0b\u63a7\u5236\u3001\u6570\u636e\u91c7\u96c6\u3001\u81ea\u52a8\u5316\u63a7\u5236\u7b49\u3002<\/p>\n
\u4e0b\u9762\u662f\u4e00\u6bb5UART\u53d1\u9001\u6570\u636e\u7684\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n
#include int main(void)<\/p>
{<\/p>
\/* \u521d\u59cb\u5316UART *\/<\/p>
UART_Init();<\/p>
\/* \u53d1\u9001\u6570\u636e *\/<\/p>
UART_SendData(0xAA);<\/p>
return 0;<\/p>
}<\/p><\/code><\/pre>\n
USART\u7684\u7279\u6027\u548c\u5de5\u4f5c\u539f\u7406<\/h2>\n
USART\uff08Universal Synchronous\/Asynchronous Receiver\/Transmitter\uff09\u662f\u4e00\u79cd\u53ef\u4ee5\u5b9e\u73b0\u540c\u6b65\u6216\u5f02\u6b65\u6570\u636e\u4f20\u8f93\u7684\u901a\u4fe1\u63a5\u53e3\u3002\u5b83\u53ef\u4ee5\u901a\u8fc7\u53d1\u9001\u548c\u63a5\u6536\u4e24\u4e2a\u4fe1\u53f7\u6765\u5b8c\u6210\u6570\u636e\u4f20\u8f93\uff0c\u53d1\u9001\u4fe1\u53f7\u7531TX\uff08Transmit\uff09\u7ebf\u8d1f\u8d23\uff0c\u63a5\u6536\u4fe1\u53f7\u7531RX\uff08Receive\uff09\u7ebf\u8d1f\u8d23\u3002USART\u53ef\u4ee5\u652f\u6301\u540c\u6b65\u548c\u5f02\u6b65\u4f20\u8f93\uff0c\u5e76\u4e14\u53ef\u4ee5\u652f\u6301\u591a\u79cd\u6570\u636e\u4f20\u8f93\u534f\u8bae\uff0c\u5982RS-232\u3001RS-485\u7b49\u3002<\/p>\n
USART\u7684\u5e94\u7528\u573a\u666f<\/h3>\n
USART\u53ef\u4ee5\u5e94\u7528\u4e8e\u5404\u79cd\u8bbe\u5907\u4e4b\u95f4\u7684\u6570\u636e\u4f20\u8f93\uff0c\u5982\u7535\u8111\u4e0e\u8bbe\u5907\u4e4b\u95f4\u7684\u6570\u636e\u4f20\u8f93\uff0c\u8bbe\u5907\u4e4b\u95f4\u7684\u6570\u636e\u4f20\u8f93\u7b49\u3002\u5b83\u53ef\u4ee5\u7528\u4e8e\u5b9e\u73b0\u5404\u79cd\u590d\u6742\u7684\u6570\u636e\u4f20\u8f93\uff0c\u5982\u8fdc\u7a0b\u63a7\u5236\u3001\u6570\u636e\u91c7\u96c6\u3001\u81ea\u52a8\u5316\u63a7\u5236\u7b49\u3002<\/p>\n
USART\u7684\u793a\u4f8b\u4ee3\u7801<\/h3>\n
\u4e0b\u9762\u662f\u4e00\u6bb5USART\u53d1\u9001\u6570\u636e\u7684\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n
#include int main(void)<\/p>
{<\/p>
\/* \u521d\u59cb\u5316USART *\/<\/p>
USART_Init();<\/p>
\/* \u53d1\u9001\u6570\u636e *\/<\/p>
USART_SendData(0xAA);<\/p>
return 0;<\/p>
}<\/p><\/code><\/pre>\n
\u603b\u7ed3<\/h2>\n
\u672c\u6587\u4ecb\u7ecd\u4e86STM32\u7684UART\u548cUSART\uff0c\u91cd\u70b9\u8bb2\u89e3\u5b83\u4eec\u7684\u7279\u6027\u3001\u5de5\u4f5c\u539f\u7406\u3001\u5e94\u7528\u573a\u666f\uff0c\u5e76\u7ed9\u51fa\u76f8\u5173\u7684\u793a\u4f8b\u4ee3\u7801\u3002<\/strong>UART\u548cUSART\u53ef\u4ee5\u7528\u4e8e\u5b9e\u73b0\u5404\u79cd\u590d\u6742\u7684\u6570\u636e\u4f20\u8f93\uff0c\u5982\u8fdc\u7a0b\u63a7\u5236\u3001\u6570\u636e\u91c7\u96c6\u3001\u81ea\u52a8\u5316\u63a7\u5236\u7b49\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"STM32\u7684UART\u548cUSART\u662f\u4e00\u79cd\u9ad8\u6027\u80fd\u7684\u901a\u4fe1\u63a5\u53e3\uff0c\u5b83\u88ab\u5e7f\u6cdb\u5e94\u7528\u4e8e\u5404\u79cd\u8bbe\u5907\u4e4b\u95f4\u7684\u6570\u636e\u4f20\u8f93\u3002\u672c\u6587\u5c06\u4ecb\u7ecdSTM32\u7684UART\u548cUSART\uff0c\u91cd\u70b9\u8bb2\u89e3\u5b83\u4eec\u7684\u7279\u6027\u3001\u5de5\u4f5c\u539f\u7406\u3001\u5e94<\/p>\n","protected":false},"author":1,"featured_media":4132,"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":[287],"class_list":["post-39100","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-stm32"],"_links":{"self":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts\/39100","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/comments?post=39100"}],"version-history":[{"count":0,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts\/39100\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/media\/4132"}],"wp:attachment":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/media?parent=39100"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/categories?post=39100"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/tags?post=39100"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}