stm32 usartr8t6的usart串口相互之间会不会干扰

STM32初始化中使能串口发送中断(USART_IT_TXE/TC)的疑问?-电子产品世界论坛
STM32初始化中使能串口发送中断(USART_IT_TXE/TC)的疑问?
&&&&在测试STM32串口发送完成中断的应用中,遇到了一个很奇怪的问题,在初始化完成之后直接就进入了串口中断函数的发送完成服务中断函数部分。本测试代码是在原来的基础上更改的,原来只使能了接受中断,此次仅仅是在初始化中加入了使能发送完成中断,所以问题的重点就处在了这个使能发送完成中断了。
&&&&查阅资料发现,在使能了发送完成中断之后,硬件就会紧接着发送一个空字符,那么发送完成之后不就进入了中断服务函数了。一般的解决方法是在初始化中不使能发送完成中断。仅是在发送数据的函数中使能发送完成中断,然后在中断函数中Disable此中断。我也试了下没有问题。
&&&&我想请教下,大家一般都是怎么处理发送完成中断(USART_IT_TXE或USART_IT_TC)的呢?
有篇介绍STM32串口中断的文章写的不错,来着分享下:
一个字符发送完成时,才能进入下一个字符的中断!
在串口初始化中尝试过使能发送中断没?
敬请高手。
这个必须要测试啊~~
话说这个发送完成中断还是非常有用的,尤其在rs485通讯中……
测试过了,我觉得在初始化中开启接收中断没大意义,因为必须在其接受中断服务函数中将其Disable掉,再在需要发送的函数中将其Enable,我就是测试Modbus 485呢,多多指点啊
匿名不能发帖!请先 [
Copyright (C) 《电子产品世界》杂志社 版权所有STM32 中断法 USART 串口简单使用_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
STM32 中断法 USART 串口简单使用
上传于||文档简介
&&S​T​M2​ ​中​断​法​ ​U​S​A​R​T​ ​串​口​简​单​使​用
阅读已结束,如果下载本文需要使用1下载券
想免费下载本文?
定制HR最喜欢的简历
你可能喜欢STM32 USART同步异步串行通讯_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
STM32 USART同步异步串行通讯
上传于||暂无简介
阅读已结束,如果下载本文需要使用0下载券
想免费下载更多文档?
定制HR最喜欢的简历
下载文档到电脑,查找使用更方便
还剩8页未读,继续阅读
定制HR最喜欢的简历
你可能喜欢6853人阅读
嵌入式系统(37)
实时操作系统(22)
在上一篇学习笔记《STM32F10x 学习笔记6(USART实现串口通讯 2)》给出了个利用环形缓冲区的串口驱动。最近研究了uCOS-II在STM32上的移植。下面再给个利用uCOS-II的信号量的串口驱动。整个驱动的基本框架和上一篇没什么区别,所以不多介绍。直接贴代码:
整个驱动包含四个文件:
COMMRTOS.H
COMMRTOS.c
其中前两个文件是对串口基本功能的封装。
uart.h 的代码如下:
#ifndef _UART_H_
#define _UART_H_
void USART1_Init(void);
void USART2_Init(void);
void UART_PutChar(USART_TypeDef* USARTx, uint8_t Data);
void UART_PutStr (USART_TypeDef* USARTx, uint8_t *str);
uint8_t UART_GetChar(USART_TypeDef* USARTx);
uart.c 的代码
#include &stm32f10x.h&
void USART1_Init(void)
GPIO_InitTypeDef GPIO_InitS
USART_InitTypeDef USART_InitS
NVIC_InitTypeDef NVIC_InitS
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_USART1, ENABLE);
/* Configure USART Tx as alternate function push-pull */
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/* Configure USART Rx as input floating */
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
GPIO_Init(GPIOA, &GPIO_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_N
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_Init(USART1, &USART_InitStructure);
USART_Cmd(USART1, ENABLE);
NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
void USART2_Init(void)
GPIO_InitTypeDef GPIO_InitS
USART_InitTypeDef USART_InitS
NVIC_InitTypeDef NVIC_InitS
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD | RCC_APB2Periph_AFIO, ENABLE);
/* Configure USART Tx as alternate function push-pull */
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOD, &GPIO_InitStructure);
/* Configure USART Rx as input floating */
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_PinRemapConfig(GPIO_Remap_USART2, ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);
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_N
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_Init(USART2, &USART_InitStructure);
USART_Cmd(USART2, ENABLE);
NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
void UART_PutChar(USART_TypeDef* USARTx, uint8_t Data)
//while (USART_GetFlagStatus(USARTx, USART_FLAG_TC) == RESET ) {};
while((USARTx-&SR & USART_FLAG_TXE) == 0x00) {};
//USART_SendData (USARTx, Data);
USARTx-&DR = D
void UART_PutStr(USART_TypeDef* USARTx, uint8_t *str)
while(0 != *str)
UART_PutChar(USARTx, *str);
uint8_t UART_GetChar(USART_TypeDef* USARTx)
//while( USART_GetFlagStatus(USARTx, USART_FLAG_RXNE) == RESET) {};
while((USARTx-&SR & USART_FLAG_RXNE) == 0x00) {};
//return USART_ReceiveData(USARTx);
return (USARTx-&DR & 0xff);
commrtos.h 的代码如下:
#ifndef _COMMRTOS_H_
#define _COMMRTOS_H_
#ifndef& CFG_H
#define& COMM_RX_BUF_SIZE&&&&& 64&&&&&&&&&&&&&&& /* Number of characters in Rx ring buffer&&&&&&&&&&&& */
#define& COMM_TX_BUF_SIZE&&&&& 64&&&&&&&&&&&&&&& /* Number of characters in Tx ring buffer&&&&&&&&&&&& */
*********************************************************************************************************
*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& CONSTANTS
*********************************************************************************************************
#ifndef& FALSE
#define& FALSE&&&&&&&&&&&&&&& 0x00
#ifndef& TRUE
#define& TRUE&&&&&&&&&&&&&&&& 0xff
#ifndef& NUL
#define& NUL&&&&&&&&&&&&&&&&& 0x00
#define& COM1&&&&&&&&&&&&&&&&& 0
#define& COM2&&&&&&&&&&&&&&&&& 1
/* ERROR CODES */
#define& COMM_NO_ERR&&&&&&&&&& 0&&&&&&&&&&&&&&& /* Function call was successful&&&&&&&&&&&&&&&&&&&&&& */
#define& COMM_BAD_CH&&&&&&&&&& 1&&&&&&&&&&&&&&& /* Invalid communications port channel&&&&&&&&&&&&&&& */
#define& COMM_RX_EMPTY&&&&&&&& 2&&&&&&&&&&&&&&& /* Rx buffer is empty, no character available&&&&&&&& */
#define& COMM_TX_FULL&&&&&&&&& 3&&&&&&&&&&&&&&& /* Tx buffer is full, could not deposit character&&&& */
#define& COMM_TX_EMPTY&&&&&&&& 4&&&&&&&&&&&&&&& /* If the Tx buffer is empty.&&&&&&&&&&&&&&&&&&&&&&&& */
#define& COMM_RX_TIMEOUT&&&&&& 5&&&&&&&&&&&&&&& /* If a timeout occurred while waiting for a character*/
#define& COMM_TX_TIMEOUT&&&&&& 6&&&&&&&&&&&&&&& /* If a timeout occurred while waiting to send a char.*/
#define& COMM_PARITY_NONE&&&&& 0&&&&&&&&&&&&&&& /* Defines for setting parity&&&&&&&&&&&&&&&&&&&&&&&& */
#define& COMM_PARITY_ODD&&&&&& 1
#define& COMM_PARITY_EVEN&&&&& 2
unsigned char CommGetChar(unsigned char ch, unsigned short to, unsigned char *err);
void COMInit(void);
unsigned char CommIsEmpty(unsigned char ch);
unsigned char CommIsFull(unsigned char ch);
unsigned char CommPutChar(unsigned char ch, unsigned char c, unsigned short to);
void CommPutStr(unsigned char ch, uint8_t *str);
commrtos.c 的代码如下:
#include &stm32f10x_usart.h&
#include &includes.h&
#include &COMMRTOS.H&
* DATA TYPES
typedef struct {
unsigned short
RingBufRxC
/* Number of characters in the Rx ring buffer
*RingBufRxS
/* Pointer to Rx semaphore
unsigned char
*RingBufRxInP
/* Pointer to where next character will be inserted
unsigned char
*RingBufRxOutP
/* Pointer from where next character will be extracted
unsigned char
RingBufRx[COMM_RX_BUF_SIZE]; /* Ring buffer character storage (Rx)
unsigned short
RingBufTxC
/* Number of characters in the Tx ring buffer
*RingBufTxS
/* Pointer to Tx semaphore
unsigned char
*RingBufTxInP
/* Pointer to where next character will be inserted
unsigned char
*RingBufTxOutP
/* Pointer from where next character will be extracted
unsigned char
RingBufTx[COMM_TX_BUF_SIZE]; /* Ring buffer character storage (Tx)
} COMM_RING_BUF;
* GLOBAL VARIABLES
COMM_RING_BUF
COMM_RING_BUF
static void COMEnableTxInt(unsigned char port)
static USART_TypeDef* map[2] = {USART1, USART2};
//USART_ITConfig(map[port], USART_IT_TXE, ENABLE);
map[port]-&CR1 |= USART_FLAG_TXE;
*********************************************************************************************************
REMOVE CHARACTER FROM RING BUFFER
* Description : This function is called by your application to obtain a character from the communications
The function will wait for a character to be received on the serial channel or
until the function times out.
* Arguments
is the COMM port channel number and can either be:
is the amount of time (in clock ticks) that the calling function is willing to
wait for a character to arrive.
If you specify a timeout of 0, the function will
wait forever for a character to arrive.
is a pointer to where an error code will be placed:
*err is set to COMM_NO_ERR
if a character has been received
*err is set to COMM_RX_TIMEOUT if a timeout occurred
*err is set to COMM_BAD_CH
if you specify an invalid channel number
: The character in the buffer (or NUL if a timeout occurred)
*********************************************************************************************************
unsigned char
CommGetChar(unsigned char ch, unsigned short to, unsigned char *err)
COMM_RING_BUF *
switch(ch)
/* Obtain pointer to communications channel */
case COM1:
pbuf = &Comm1B
case COM2:
pbuf = &Comm2B
*err = COMM_BAD_CH;
return (NUL);
OSSemPend(pbuf-&RingBufRxSem, to, &oserr);
/* Wait for character to arrive
if(oserr == OS_TIMEOUT)
/* See if characters received within timeout*/
*err = COMM_RX_TIMEOUT;
/* No, return error code
return (NUL);
OS_ENTER_CRITICAL();
pbuf-&RingBufRxCtr--;
/* Yes, decrement character count
c = *pbuf-&RingBufRxOutPtr++;
/* Get character from buffer
if(pbuf-&RingBufRxOutPtr == &pbuf-&RingBufRx[COMM_RX_BUF_SIZE])
/* Wrap OUT pointer
pbuf-&RingBufRxOutPtr = &pbuf-&RingBufRx[0];
OS_EXIT_CRITICAL();
*err = COMM_NO_ERR;
return (c);
void CommPutStr(unsigned char ch, uint8_t *str)
while(0 != *str)
CommPutChar(ch, *str, 0);
static unsigned char
COMGetTxChar(unsigned char ch, unsigned char *err)
COMM_RING_BUF *
switch(ch)
/* Obtain pointer to communications channel */
case COM1:
pbuf = &Comm1B
case COM2:
pbuf = &Comm2B
*err = COMM_BAD_CH;
return (NUL);
if(pbuf-&RingBufTxCtr & 0)
/* See if buffer is empty
pbuf-&RingBufTxCtr--;
/* No, decrement character count
c = *pbuf-&RingBufTxOutPtr++;
/* Get character from buffer
if(pbuf-&RingBufTxOutPtr == &pbuf-&RingBufTx[COMM_TX_BUF_SIZE])
/* Wrap OUT pointer
pbuf-&RingBufTxOutPtr = &pbuf-&RingBufTx[0];
OSSemPost(pbuf-&RingBufTxSem);
/* Indicate that character will be sent
*err = COMM_NO_ERR;
return (c);
/* Characters are still available
*err = COMM_TX_EMPTY;
return (NUL);
/* Buffer is empty
*********************************************************************************************************
INITIALIZE COMMUNICATIONS MODULE
* Description : This function is called by your application to initialize the communications module.
must call this function before calling any other functions.
* Arguments
*********************************************************************************************************
COMInit(void)
COMM_RING_BUF *
/* Initialize the ring buffer for COMM1
pbuf-&RingBufRxCtr
pbuf-&RingBufRxInPtr
= &pbuf-&RingBufRx[0];
pbuf-&RingBufRxOutPtr = &pbuf-&RingBufRx[0];
pbuf-&RingBufRxSem
= OSSemCreate(0);
pbuf-&RingBufTxCtr
pbuf-&RingBufTxInPtr
= &pbuf-&RingBufTx[0];
pbuf-&RingBufTxOutPtr = &pbuf-&RingBufTx[0];
pbuf-&RingBufTxSem
= OSSemCreate(COMM_TX_BUF_SIZE);
/* Initialize the ring buffer for COMM2
pbuf-&RingBufRxCtr
pbuf-&RingBufRxInPtr
= &pbuf-&RingBufRx[0];
pbuf-&RingBufRxOutPtr = &pbuf-&RingBufRx[0];
pbuf-&RingBufRxSem
= OSSemCreate(0);
pbuf-&RingBufTxCtr
pbuf-&RingBufTxInPtr
= &pbuf-&RingBufTx[0];
pbuf-&RingBufTxOutPtr = &pbuf-&RingBufTx[0];
pbuf-&RingBufTxSem
= OSSemCreate(COMM_TX_BUF_SIZE);
*********************************************************************************************************
SEE IF RX CHARACTER BUFFER IS EMPTY
* Description : This function is called by your application to see if any character is available from the
communications channel.
If at least one character is available, the function returns
FALSE otherwise, the function returns TRUE.
* Arguments
is the COMM port channel number and can either be:
if the buffer IS empty.
if the buffer IS NOT empty or you have specified an incorrect channel.
*********************************************************************************************************
unsigned char CommIsEmpty(unsigned char ch)
COMM_RING_BUF *
switch(ch)
/* Obtain pointer to communications channel */
case COM1:
pbuf = &Comm1B
case COM2:
pbuf = &Comm2B
return (TRUE);
OS_ENTER_CRITICAL();
if(pbuf-&RingBufRxCtr & 0)
/* See if buffer is empty
empty = FALSE;
/* Buffer is NOT empty
empty = TRUE;
/* Buffer is empty
OS_EXIT_CRITICAL();
return (empty);
*********************************************************************************************************
SEE IF TX CHARACTER BUFFER IS FULL
* Description : This function is called by your application to see if any more characters can be placed
in the Tx buffer.
In other words, this function check to see if the Tx buffer is full.
If the buffer is full, the function returns TRUE otherwise, the function returns FALSE.
* Arguments
is the COMM port channel number and can either be:
if the buffer IS full.
if the buffer IS NOT full or you have specified an incorrect channel.
*********************************************************************************************************
unsigned char CommIsFull(unsigned char ch)
COMM_RING_BUF *
switch(ch)
/* Obtain pointer to communications channel */
case COM1:
pbuf = &Comm1B
case COM2:
pbuf = &Comm2B
return (TRUE);
OS_ENTER_CRITICAL();
if(pbuf-&RingBufTxCtr & COMM_TX_BUF_SIZE)
/* See if buffer is full
full = FALSE;
/* Buffer is NOT full
full = TRUE;
/* Buffer is full
OS_EXIT_CRITICAL();
return (full);
*********************************************************************************************************
OUTPUT CHARACTER
* Description : This function is called by your application to send a character on the communications
The function will wait for the buffer to empty out if the buffer is full.
The function returns to your application if the buffer doesn't empty within the specified
A timeout value of 0 means that the calling function will wait forever for the
buffer to empty out.
The character to send is first inserted into the Tx buffer and will
be sent by the Tx ISR.
If this is the first character placed into the buffer, the Tx ISR
will be enabled.
* Arguments
is the COMM port channel number and can either be:
is the character to send.
is the timeout (in clock ticks) to wait in case the buffer is full.
specify a timeout of 0, the function will wait forever for the buffer to empty.
: COMM_NO_ERR
if the character was placed in the Tx buffer
COMM_TX_TIMEOUT
if the buffer didn't empty within the specified timeout period
COMM_BAD_CH
if you specify an invalid channel number
*********************************************************************************************************
unsigned char CommPutChar(unsigned char ch, unsigned char c, unsigned short to)
COMM_RING_BUF *
OS_CPU_SR cpu_
switch(ch)
/* Obtain pointer to communications channel */
case COM1:
pbuf = &Comm1B
case COM2:
pbuf = &Comm2B
return (COMM_BAD_CH);
OSSemPend(pbuf-&RingBufTxSem, to, &oserr);
/* Wait for space in Tx buffer
if(oserr == OS_TIMEOUT)
return (COMM_TX_TIMEOUT);
/* Timed out, return error code
OS_ENTER_CRITICAL();
pbuf-&RingBufTxCtr++;
/* No, increment character count
*pbuf-&RingBufTxInPtr++ =
/* Put character into buffer
if(pbuf-&RingBufTxInPtr == &pbuf-&RingBufTx[COMM_TX_BUF_SIZE])
/* Wrap IN pointer
pbuf-&RingBufTxInPtr = &pbuf-&RingBufTx[0];
if(pbuf-&RingBufTxCtr == 1)
/* See if this is the first character
COMEnableTxInt(ch);
/* Yes, Enable Tx interrupts
OS_EXIT_CRITICAL();
return (COMM_NO_ERR);
*********************************************************************************************************
INSERT CHARACTER INTO RING BUFFER
* Description : This function is called by the Rx ISR to insert a character into the receive ring buffer.
* Arguments
is the COMM port channel number and can either be:
is the character to insert into the ring buffer.
If the buffer is full, the
character will not be inserted, it will be lost.
*********************************************************************************************************
static void COMPutRxChar(unsigned char ch, unsigned char c)
COMM_RING_BUF *
switch(ch)
/* Obtain pointer to communications channel */
case COM1:
pbuf = &Comm1B
case COM2:
pbuf = &Comm2B
if(pbuf-&RingBufRxCtr & COMM_RX_BUF_SIZE)
/* See if buffer is full
pbuf-&RingBufRxCtr++;
/* No, increment character count
*pbuf-&RingBufRxInPtr++ =
/* Put character into buffer
if(pbuf-&RingBufRxInPtr == &pbuf-&RingBufRx[COMM_RX_BUF_SIZE])
/* Wrap IN pointer
pbuf-&RingBufRxInPtr = &pbuf-&RingBufRx[0];
OSSemPost(pbuf-&RingBufRxSem);
/* Indicate that character was received
// This function is called by the Rx ISR to insert a character into the receive ring buffer.
void USART1_IRQHandler(void)
OS_ENTER_CRITICAL();
/* Tell uC/OS-II that we are starting an ISR
OSIntNesting++;
OS_EXIT_CRITICAL();
if(USART1-&SR & 0x0F)
// See if we have some kind of error
// Clear interrupt (do nothing about it!)
data = USART1-&DR;
else if(USART1-&SR & USART_FLAG_RXNE) //Receive Data Reg Full Flag
data = USART1-&DR;
COMPutRxChar(COM1, data);
// Insert received character into buffer
else if(USART1-&SR & USART_FLAG_TXE)
data = COMGetTxChar(COM1, &err);
// Get next character to send.
if(err == COMM_TX_EMPTY)
// Do we have anymore characters to send ?
Disable Tx interrupts
//USART_ITConfig(USART1, USART_IT_TXE| USART_IT_TC, DISABLE);
USART1-&CR1 &= ~USART_FLAG_TXE | USART_FLAG_TC;
USART1-&DR =
// Yes, Send character
OSIntExit();
void USART2_IRQHandler(void)
OS_ENTER_CRITICAL();
/* Tell uC/OS-II that we are starting an ISR
OSIntNesting++;
OS_EXIT_CRITICAL();
if(USART2-&SR & 0x0F)
// See if we have some kind of error
// Clear interrupt (do nothing about it!)
data = USART2-&DR;
else if(USART2-&SR & USART_FLAG_RXNE) //Receive Data Reg Full Flag
data = USART2-&DR;
COMPutRxChar(COM2, data);
// Insert received character into buffer
else if(USART2-&SR & USART_FLAG_TXE)
data = COMGetTxChar(COM2, &err);
// Get next character to send.
if(err == COMM_TX_EMPTY)
// Do we have anymore characters to send ?
Disable Tx interrupts
//USART_ITConfig(USART2, USART_IT_TXE| USART_IT_TC, DISABLE);
USART2-&CR1 &= ~USART_FLAG_TXE | USART_FLAG_TC;
USART2-&DR =
// Yes, Send character
OSIntExit();
下面再给出个测试代码:
#include &stm32f10x.h&
#include &uart.h&
#include &led.h&
#include &COMMRTOS.H&
#include &ucos_ii.h&
TASK_STK_SIZE 128
OS_STK TaskStartStk[TASK_STK_SIZE];
OS_STK TaskUartReadStk[TASK_STK_SIZE];
void TaskUartRead(void *pdata)
c = CommGetChar(COM2, 0, &err);
if(err == COMM_NO_ERR)
CommPutChar(COM2, c, 0);
void TaskStart(void *pdata)
SysTick_Config(SystemCoreClock/10);
USART1_Init();
USART2_Init();
COMInit();
//USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);
//USART_ITConfig(USART2, USART_IT_RXNE, ENABLE);
USART1-&CR1 |= USART_FLAG_RXNE;
USART2-&CR1 |= USART_FLAG_RXNE;
OSTaskCreate(TaskUartRead, (void *)0, &(TaskUartReadStk[TASK_STK_SIZE-1]), 2);
UART_PutStr (USART2, &USART2 Hello World!\n\r&);
//CommPutChar(COM2, '+', 0);
CommPutStr(COM2, &CommPutCharB\n\r&);
LED_Spark();
CommPutChar(COM2, '+', 0);
OSTimeDly(10);
int main(void)
SystemInit();
LED_Init();
OSTaskCreate(TaskStart, (void *)0, &(TaskStartStk[TASK_STK_SIZE-1]), 1);
OSStart();
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:1358853次
积分:16392
积分:16392
排名:第447名
原创:338篇
转载:16篇
译文:15篇
评论:566条
文章:20篇
阅读:21736
文章:32篇
阅读:48944
文章:11篇
阅读:47513
文章:22篇
阅读:93465
文章:31篇
阅读:113952
(2)(7)(7)(9)(15)(9)(22)(21)(5)(7)(4)(6)(3)(5)(4)(5)(6)(4)(2)(1)(9)(4)(4)(7)(6)(2)(3)(4)(9)(8)(2)(3)(8)(2)(6)(2)(3)(3)(4)(8)(4)(4)(14)(1)(10)(6)(2)(6)(13)(17)(11)(19)(24)}

我要回帖

更多关于 stm32 usart2 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信