程序如下 麻烦大神帮我想想
#include <stc12c5a32s2.h>
#include "usart.h"
#include "delay.h"
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
uchar num = 0;
uchar flag=0;
uchar i;
uchar n;
uchar RBuf[4];
/*------------------主程序--------------------*/
void main(void)
{
// uchar key ;
Delay1ms();
ConfigUART();
lcd_init();
lcd_clr();
// key = Key_Scan();
dprintf(16,0,"欢 迎 光 临",0);
while(1)
{
if(flag == 1)//当接收到数据
{
ES = 0;//关闭串口中断
for(i=0;i<4;i++)
{
SBUF = RBuf[i];
while(!TI); TI = 0;
}
ES = 1;
flag = 0;
num = 0;
}
}
void Uart_Isr() interrupt 4 using 1
{
if(RI)
{
RBuf[num] = SBUF;
while(!RI);
RI = 0;
num++;
}
if(num == 4) flag = 1;
} |