<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > stm32快速學(xué)習(xí)4——串口發(fā)送字符

          stm32快速學(xué)習(xí)4——串口發(fā)送字符

          作者: 時(shí)間:2016-11-17 來(lái)源:網(wǎng)絡(luò) 收藏
          設(shè)定UART1時(shí)鐘

          設(shè)定發(fā)送腳功能

          本文引用地址:http://www.ex-cimer.com/article/201611/315443.htm

          串口設(shè)置,使能

          #include"stm32f10x.h"

          voidRCC_Configuration(void);

          voidGPIO_Configuration(void);

          voidUSART_Configuration(void);

          unsignedcharstr[]="A";

          intmain(void)

          {

          RCC_Configuration();

          GPIO_Configuration();

          USART_Configuration();

          USART_SendData(USART1,str[0]);

          while(1);

          }

          voidRCC_Configuration(void)

          {

          RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1 |RCC_APB2Periph_GPIOA,ENABLE);

          }

          voidGPIO_Configuration(void)

          {

          GPIO_InitTypeDefGPIO_InitStructure;

          /*只設(shè)定了發(fā)送*/

          GPIO_InitStructure.GPIO_Pin=GPIO_Pin_9;

          GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;

          GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AF_PP;

          GPIO_Init(GPIOA,&GPIO_InitStructure);

          }

          voidUSART_Configuration(void)

          {

          USART_InitTypeDefUSART_InitStructure;

          USART_InitStructure.USART_BaudRate=115200;

          USART_InitStructure.USART_WordLength=USART_WordLength_8b;

          USART_InitStructure.USART_StopBits=USART_StopBits_1;

          USART_InitStructure.USART_Parity=USART_Parity_No;

          USART_InitStructure.USART_HardwareFlowControl=USART_HardwareFlowControl_None;

          USART_InitStructure.USART_Mode=USART_Mode_Tx;/*只設(shè)定了發(fā)送*/

          USART_Init(USART1,&USART_InitStructure);

          USART_Cmd(USART1,ENABLE);

          }



          關(guān)鍵詞: stm32串口發(fā)送字

          評(píng)論


          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();