98国产精品综合一区二区三区,国产福利视频,男人添女人囗交做爰视频,日本免费一区二区三区视频观看

你好!歡迎來(lái)到深圳市穎特新科技有限公司!
語(yǔ)言
當(dāng)前位置:首頁(yè) >> 技術(shù)中心 >> 單片機(jī)入門(mén) >> STM32的串口配置(中斷方式)

STM32的串口配置(中斷方式)

關(guān)鍵字:STM 串口 中斷方式 作者:admin 來(lái)源:不詳 發(fā)布時(shí)間:2018-05-19  瀏覽:25

STM32的串口中斷配置,也是很簡(jiǎn)單的.

首先是配置UART的GPIO口

首先是配置UART的GPIO口

/*******************************************************************************

* Name : UART1_GPIO_Configuration

* Deion : Configures the uart1 GPIO ports.

* Input : None

* Output : None

* Return : None

*******************************************************************************/

void UART1_GPIO_Configuration(void)

{

GPIO_InitTypeDef GPIO_InitStructure;

// Configure USART1_Tx as alternate push-pull

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);

// Configure USART1_Rx as input floating

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;

GPIO_Init(GPIOA, &GPIO_InitStructure);

}

然后是配置串口參數(shù)

/*******************************************************************************

* Name : UART1_Configuration

* Deion : Configures the uart1

* Input : None

* Output : None

* Return : None

*******************************************************************************/

void USART_Configuration(void)

{

USART_InitTypeDef USART_InitStructure;

USART_ClockInitTypeDef USART_ClockInitStructure;

Uart1_GPIO_Configuration();

USART_ClockInitStructure.USART_Clock = USART_Clock_Disable;

USART_ClockInitStructure.USART_CPOL = USART_CPOL_Low;

USART_ClockInitStructure.USART_CPHA = USART_CPHA_2Edge;

USART_ClockInitStructure.USART_LastBit = USART_LastBit_Disable;

/* Configure the USART1 synchronous paramters */

USART_ClockInit(USART1, &USART_ClockInitStructure);

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;

/* Configure USART1 basic and asynchronous paramters */

USART_Init(USART1, &USART_InitStructure);

/* Enable USART1 Receive interrupts */

USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);

/* Enable USART1 */

USART_Cmd(USART1, ENABLE);

}

然后是在中斷設(shè)置,需要修改stm32f10x_it.c 中的串口中斷函數(shù) 并且需要修改void NVIC_Configuration(void)函數(shù)

修改NVIC_Configuration函數(shù)

/*******************************************************************************

* Name : NVIC_Configuration

* Deion : Configures NVIC and Vector Table base location.

* Input : None

* Output : None

* Return : None

*******************************************************************************/

void NVIC_Configuration(void)

{

NVIC_InitTypeDef NVIC_InitStructure;

#ifdef VECT_TAB_RAM

/* Set the Vector Table base location at 0x20000000 */

NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0);

#else /* VECT_TAB_FLASH */

/* Set the Vector Table base location at 0x08000000 */

NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);

#endif

/* Configure the NVIC Preemption Priority Bits */

NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);

/* Enable the USART1 Interrupt */

NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQChannel;

NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;

NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

NVIC_Init(&NVIC_InitStructure);

}

//串口中斷

void USART1_IRQHandler(void)

{

//處理接收到的數(shù)據(jù)

if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET)

{

/* Clear the USART1 Receive interrupt */

USART_ClearITPendingBit(USART1, USART_IT_RXNE);

}

//發(fā)送中斷

if (USART_GetITStatus(USART1, USART_IT_TXE) != RESET)

{

USART_SendData(USART1, Send_Data[Send_Length++]);

if (Send_Length==SEND_LENGTH)

{

//發(fā)送字節(jié)結(jié)束

USART_ClearITPendingBit(USART1,USART_IT_TXE);

USART_ITConfig(USART1, USART_IT_TXE, DISABLE);

USART_ITConfig(USART1, USART_IT_TC, ENABLE);

}

}

//發(fā)送完成

if (USART_GetITStatus(USART1, USART_IT_TC) != RESET)

{

USART_ClearITPendingBit(USART1,USART_IT_TC);

USART_ITConfig(USART1, USART_IT_TC, DISABLE);

}

}

在需要發(fā)送的程序里Send_Data[SEND_LENGTH]和發(fā)送長(zhǎng)度設(shè)置好,

void Send_to_PC(void)

{

//設(shè)置好Send_Data[SEND_LENGTH]數(shù)組

//打開(kāi)發(fā)送中斷

USART_ITConfig(USART1, USART_IT_TXE, ENABLE);

}

至此 串口就可以工作起來(lái)了!~

擴(kuò)展閱讀:?jiǎn)纹瑱C(jī)串行接口

編輯:admin  最后修改時(shí)間:2018-05-19

聯(lián)系方式

0755-82591179

郵箱:ivy@yingtexin.net

地址:深圳市龍華區(qū)民治街道民治大道973萬(wàn)眾潤(rùn)豐創(chuàng)業(yè)園A棟2樓A09

Copyright © 2014-2025 穎特新科技有限公司 All Rights Reserved.  粵ICP備14043402號(hào)-4

欧美性猛交aaaa片黑人| 真人做愛三級片| 美妇身上销魂冲刺享受| 黑人狂躁中国人的a片| 真人做人试看60分钟免费视频| 日本片在线看的免费网站| 狂躁女人双腿流白色液体| 国产亚洲精品久久久久久| 丰满乳亲伦小说| 国产精品嫩草久久久久| 欧美激情精品久久久久久| 再深一点灬流出白色液体| 国产又黄又爽又猛免费视频播放| 穷山沟里的荒唐性史| 一出一进一爽一粗一大视频| 国产精品黄黄久久久免费看| 久久久欧美国产精品人妻噜噜| 永久免费观看不收费的软件5| 国产人妻精品一区二区三区不卡| 夹得好湿真拔不出来了动态图| 一层一层剥掉女生的衣服的游戏| 国产精品一区二区久久| 久久精品丝袜高跟鞋| 亚洲国产精品久久久久爰色欲| 成人性生交大片免费看京东小视频| 久久综合狠狠综合久久综合88| 曰本女人与公guo交酡视频a片| 色戒完整版无删减158分钟hd| 亚洲av无码乱码国产麻豆| 乖女从小调教h尿便器| 色情久久久av熟女人妻网站| 一区二区三区视频| 帅小伙自慰videogay男男| 丁香花在线影院观看在线播放| 高潮时粗俗不堪入耳的话| 久久久久精品免费a片喷水| 成熟女人优雅涵养说说| 军人的粗大h拔不出来| 凹凸久久人人澡超碰凹凸| 欧美性猛交xxxx乱大交蜜桃| 丰满人妻中伦妇伦精品app|