stm32串口可以发送字符串,但是中断接收后,主函数发送,串口助手没有显示接收,不知是中断函数哪里
没写对?求高手指教....
//中断函数
#include "stm32f2xx_it.h"
#include "main.h"
#include "usart_tx.h"
extern u8 USART_REC_Finish_FLAG;
extern uint8_t Receive_data[];
void USART1_IRQHandler(void)
{
uint8_t tmp=0,count=0;
if(USART_GetITStatus(USART1,USART_IT_RXNE)!=RESET)
{
USART_ClearITPendingBit(USART1,USART_IT_RXNE);
Receive_data[count++] =USART_ReceiveData(USART1 );
if(Receive_data[count]=='\n')
{
USART_REC_Finish_FLAG=1;
count=0;
}
}
}
//主函数
#include "usart_tx.h"
#include "bsp_rcc_config.h"
#include "bsp_gpio.h"
#include "usart_tx.h"
uint8_t Receive_data[]={0};
u8 USART_REC_Finish_FLAG=0;
int main()
{
RCC_HSI_config(16, 288,4,4);//配置内部时钟
USART_config();
USART_sendstring( USART1,"Important technolage");
if(USART_REC_Finish_FLAG==1)//判断标志位置1,则发送接收的数据
{
USART_REC_Finish_FLAG=0;
USART_sendArray( USART1,Receive_data,5);
}
}
|