亚洲春色中文字幕久久久-三上亚,一吻二脱三床四吻胸,国产真实伦对白视频全集,在线毛片观看,精品成品入口黄网,国产毛aⅴ片久久久,亚洲AV色香蕉一区二区三区老师,萧皇后A级艳片,色情日本视频更新,99久久亚洲精品日本无码

標題: stm32串口2通信 USART2(發(fā)送數(shù)據(jù))程序 [打印本頁]

作者: geige    時間: 2015-7-26 02:13
標題: stm32串口2通信 USART2(發(fā)送數(shù)據(jù))程序
#include "stm32f10x.h"
void Delay(unsigned int x);
void GPIO_Configuration(void);
void UART_Init(void);
void UART2_PutChar(u8 ch);

int main(void)
{
   SystemInit();
   unsigned int temp;
   GPIO_Configuration();
   UART_Init();
   while(1)
   {
     for(temp=0;temp<50;temp++)
    {Delay(65500);}
     UART2_PutChar(0x55);
   }

}


void GPIO_Configuration(void)
{
   GPIO_InitTypeDefGPIO_InitStructure;
   RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2,ENABLE); //USART2時鐘在APB1上
   RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_AFIO, ENABLE);
   GPIO_InitStructure.GPIO_Pin =GPIO_Pin_2;
   GPIO_InitStructure.GPIO_Mode =GPIO_Mode_AF_PP;
   GPIO_InitStructure.GPIO_Speed= GPIO_Speed_50MHz;
   GPIO_Init(GPIOA,&GPIO_InitStructure);
   
   GPIO_InitStructure.GPIO_Pin =GPIO_Pin_3;
   GPIO_InitStructure.GPIO_Mode =GPIO_Mode_IN_FLOATING;
   GPIO_InitStructure.GPIO_Speed= GPIO_Speed_50MHz;
   GPIO_Init(GPIOA,&GPIO_InitStructure);
}

void UART_Init(void)
{
   
   
    USART_InitTypeDefUSART_InitStructure;
   USART_InitStructure.USART_BaudRate = 9600;
   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_Rx |USART_Mode_Tx;

    USART_Init(USART2,&USART_InitStructure);
    USART_Cmd(USART2,ENABLE);
}

void UART2_PutChar(u8 ch)
{
  USART_SendData(USART2,ch);
  while(USART_GetFlagStatus(USART2,USART_FLAG_TXE)== RESET);
}


void Delay(unsigned int x)
{
unsigned int t;
t=x;
while(t--);
}



切記!!!在options設置中C/C++ Compiler的Preprocessor選項卡的defined symbols中填入STM32F10X_HD需要和你的芯片類型對應!!否則發(fā)送錯誤!!


startup_stm32f10x_cl.s互聯(lián)型的器件,STM32F105xx,STM32F107xx
startup_stm32f10x_hd.s大容量的STM32F101xx,STM32F102xx,STM32F103xx
startup_stm32f10x_hd_vl.s 大容量的STM32F100xx
startup_stm32f10x_ld.s小容量的STM32F101xx,STM32F102xx,STM32F103xx
startup_stm32f10x_ld_vl.s 小容量的STM32F100xx
startup_stm32f10x_md.s中容量的STM32F101xx,STM32F102xx,STM32F103xx
startup_stm32f10x_md_vl.s 中容量的STM32F100xx
startup_stm32f10x_xl.sFLASH在512K到1024K字節(jié)的STM32F101xx,STM32F102xx,STM32F103xx



作者: wxc19960311    時間: 2017-11-9 13:33
你好,我可以借鑒一下你的工程碼,方便的話QQ1306501801謝謝




歡迎光臨 (http://www.denmoz.com/bbs/) Powered by Discuz! X3.1