{"id":38820,"date":"2023-10-04T23:29:51","date_gmt":"2023-10-04T15:29:51","guid":{"rendered":"https:\/\/www.techphant.cn\/?p=38820"},"modified":"2023-10-04T23:29:51","modified_gmt":"2023-10-04T15:29:51","slug":"scksfjx","status":"publish","type":"post","link":"https:\/\/www.techphant.cn\/blog\/38820.html","title":{"rendered":"STM32F103C8T6\u4e32\u53e3\u6536\u53d1\u63a5\u7ebf"},"content":{"rendered":"
STM32F103C8T6\u4e32\u53e3\u6536\u53d1\u63a5\u7ebf\u662f\u4e00\u79cd\u901a\u7528\u7684\u63a5\u7ebf\u65b9\u5f0f\uff0c\u4e3b\u8981\u7528\u4e8eSTM32F103C8T6\u5355\u7247\u673a\u7684\u4e32\u53e3\u901a\u4fe1\u3002\u5b83\u63d0\u4f9b\u4e86\u4e00\u79cd\u7b80\u5355\u3001\u53ef\u9760\u3001\u7a33\u5b9a\u7684\u901a\u4fe1\u65b9\u5f0f\uff0c\u53ef\u4ee5\u4e3aSTM32F103C8T6\u5355\u7247\u673a\u63d0\u4f9b\u5feb\u901f\u7684\u4e32\u53e3\u901a\u4fe1\u3002<\/p>\n
STM32F103C8T6\u4e32\u53e3\u6536\u53d1\u63a5\u7ebf\u7684\u786c\u4ef6\u8fde\u63a5\u65b9\u5f0f\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u8981\u628aSTM32F103C8T6\u7684TXD\u3001RXD\u548cGND\u5f15\u811a\u8fde\u63a5\u5230\u63a5\u6536\u8bbe\u5907\u7684RXD\u3001TXD\u548cGND\u5f15\u811a\u4e0a\u5373\u53ef\u3002\u5177\u4f53\u7684\u63a5\u7ebf\u65b9\u5f0f\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n
\u5728\u786c\u4ef6\u8fde\u63a5\u5b8c\u6210\u4e4b\u540e\uff0c\u6211\u4eec\u8fd8\u9700\u8981\u5bf9STM32F103C8T6\u5355\u7247\u673a\u7684\u8f6f\u4ef6\u8fdb\u884c\u914d\u7f6e\uff0c\u4ee5\u786e\u4fdd\u4e32\u53e3\u7684\u6b63\u5e38\u5de5\u4f5c\u3002\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u4f7f\u7528Keil uVision\u8f6f\u4ef6\u6253\u5f00STM32F103C8T6\u5355\u7247\u673a\u7684\u5de5\u7a0b\u6587\u4ef6\uff0c\u7136\u540e\u6253\u5f00\u201c\u4e32\u53e3\u914d\u7f6e\u201d\u7a97\u53e3\uff0c\u9009\u62e9\u201c\u4e32\u53e31\u201d\uff0c\u5e76\u8bbe\u7f6e\u4e32\u53e3\u7684\u6ce2\u7279\u7387\uff0c\u5982\u56fe\u6240\u793a\uff1a<\/p>\n
\u5728\u786c\u4ef6\u8fde\u63a5\u548c\u8f6f\u4ef6\u914d\u7f6e\u5b8c\u6210\u4e4b\u540e\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u5f00\u59cb\u7f16\u5199\u7a0b\u5e8f\u6765\u5b9e\u73b0STM32F103C8T6\u4e32\u53e3\u6536\u53d1\u63a5\u7ebf\u7684\u529f\u80fd\u4e86\u3002\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u5728\u7a0b\u5e8f\u4e2d\u5305\u542b\u4e32\u53e3\u5934\u6587\u4ef6\uff0c\u7136\u540e\u521d\u59cb\u5316\u4e32\u53e3\uff0c\u6700\u540e\u4f7f\u7528\u4e32\u53e3\u53d1\u9001\u548c\u63a5\u6536\u6570\u636e\u5373\u53ef\u3002\u5177\u4f53\u7684\u7f16\u7a0b\u5b9e\u73b0\u5982\u4e0b\uff1a<\/p>\n
#include “stm32f10x.h”<\/p>\n
#include “stm32f10x_usart.h”<\/p>\n
void USART_Init(void)<\/p>\n
{<\/p>\n
GPIO_InitTypeDef GPIO_InitStructure;<\/p>\n
USART_InitTypeDef USART_InitStructure;<\/p>\n
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_USART1, ENABLE);<\/p>\n
\/\/TX<\/p>\n
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;<\/p>\n
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;<\/p>\n
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;<\/p>\n
GPIO_Init(GPIOA, &GPIO_InitStructure);<\/p>\n
\/\/RX<\/p>\n
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;<\/p>\n
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;<\/p>\n
GPIO_Init(GPIOA, &GPIO_InitStructure);<\/p>\n
USART_InitStructure.USART_BaudRate = 115200;<\/p>\n
USART_InitStructure.USART_WordLength = USART_WordLength_8b;<\/p>\n
USART_InitStructure.USART_StopBits = USART_StopBits_1;<\/p>\n
USART_InitStructure.USART_Parity = USART_Parity_No;<\/p>\n
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;<\/p>\n
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;<\/p>\n
USART_Init(USART1, &USART_InitStructure);<\/p>\n
USART_Cmd(USART1, ENABLE);<\/p>\n
}<\/p>\n
void USART_SendData(USART_TypeDef *USARTx, uint8_t Data)<\/p>\n
{<\/p>\n
USART_SendData(USARTx, Data);<\/p>\n
while(USART_GetFlagStatus(USARTx, USART_FLAG_TXE) == RESET);<\/p>\n
}<\/p>\n
uint8_t USART_ReceiveData(USART_TypeDef *USARTx)<\/p>\n
{<\/p>\n
while(USART_GetFlagStatus(USARTx, USART_FLAG_RXNE) == RESET);<\/p>\n
return USART_ReceiveData(USARTx);<\/p>\n
}<\/p>\n
STM32F103C8T6\u4e32\u53e3\u6536\u53d1\u63a5\u7ebf\u662f\u4e00\u79cd\u5e38\u89c1\u7684\u63a5\u7ebf\u65b9\u5f0f\uff0c\u5b83\u63d0\u4f9b\u4e86\u4e00\u79cd\u7b80\u5355\u3001\u53ef\u9760\u3001\u7a33\u5b9a\u7684\u901a\u4fe1\u65b9\u5f0f\uff0c\u53ef\u4ee5\u4e3aSTM32F103C8T6\u5355\u7247\u673a\u63d0\u4f9b\u5feb\u901f\u7684\u4e32\u53e3\u901a\u4fe1\u3002\u5b83\u7684\u63a5\u7ebf\u65b9\u5f0f\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u8981\u628aSTM32F103C8T6\u7684TXD\u3001RXD\u548cGND\u5f15\u811a\u8fde\u63a5\u5230\u63a5\u6536\u8bbe\u5907\u7684RXD\u3001TXD\u548cGND\u5f15\u811a\u4e0a\u5373\u53ef\u3002\u6b64\u5916\uff0c\u6211\u4eec\u8fd8\u9700\u8981\u5bf9STM32F103C8T6\u5355\u7247\u673a\u7684\u8f6f\u4ef6\u8fdb\u884c\u914d\u7f6e\uff0c\u7f16\u5199\u7a0b\u5e8f\u6765\u5b9e\u73b0STM32F103C8T6\u4e32\u53e3\u6536\u53d1\u63a5\u7ebf\u7684\u529f\u80fd\uff0c\u4ee5\u786e\u4fdd\u4e32\u53e3\u7684\u6b63\u5e38\u5de5\u4f5c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"
STM32F103C8T6\u4e32\u53e3\u6536\u53d1\u63a5\u7ebf\u662f\u4e00\u79cd\u901a\u7528\u7684\u63a5\u7ebf\u65b9\u5f0f\uff0c\u4e3b\u8981\u7528\u4e8eSTM32F103C8T6\u5355\u7247\u673a\u7684\u4e32\u53e3\u901a\u4fe1\u3002\u5b83\u63d0\u4f9b\u4e86\u4e00\u79cd\u7b80\u5355\u3001\u53ef\u9760\u3001\u7a33\u5b9a\u7684\u901a\u4fe1\u65b9\u5f0f\uff0c\u53ef\u4ee5\u4e3aST<\/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-38820","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\/38820","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=38820"}],"version-history":[{"count":0,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts\/38820\/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=38820"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/categories?post=38820"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/tags?post=38820"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}