串口助手向51单片机发送一个指令(AA),单片机接收到(AA)后先把P1灯全部打开,延时1S后熄灭
但是现在出现问题,P1灯能打开,但是打开之后不熄灭,求各位大神指教,波特率设的是9600,程序如下:#include"REG52.H"#defineuintunsigne...
但是现在出现问题,P1灯能打开,但是打开之后不熄灭,求各位大神指教,波特率设的是9600,程序如下:
#include "REG52.H"
#define uint unsigned int
#define uchar unsigned char
uchar MAIN_FLG;
uchar MAIN_BUF;
uchar Cverrput[5];
void delayms(uint xms)
{
uint i,j;
for(i=xms;i>0;i--)
for(j=110;j>0;j--);
}
void SysemInit(void)
{
TMOD = 0x20;
TH1 = 0xFD;
TL1 = 0xFD;
TR1 = 1;
REN = 1;
SM0 = 0;
SM1 = 1;
ES = 1;
EA = 1;
}
int main(void)
{
SysemInit();
while(1)
{
if(MAIN_BUF==0xAA)
{
P1 = 0x00;
delayms(1000);
P1 = 0xFF;
}
}
}
void USART_TI(void) interrupt 4
{
while(RI == 1)
{
MAIN_BUF = SBUF;
RI = 0;
}
} 展开
#include "REG52.H"
#define uint unsigned int
#define uchar unsigned char
uchar MAIN_FLG;
uchar MAIN_BUF;
uchar Cverrput[5];
void delayms(uint xms)
{
uint i,j;
for(i=xms;i>0;i--)
for(j=110;j>0;j--);
}
void SysemInit(void)
{
TMOD = 0x20;
TH1 = 0xFD;
TL1 = 0xFD;
TR1 = 1;
REN = 1;
SM0 = 0;
SM1 = 1;
ES = 1;
EA = 1;
}
int main(void)
{
SysemInit();
while(1)
{
if(MAIN_BUF==0xAA)
{
P1 = 0x00;
delayms(1000);
P1 = 0xFF;
}
}
}
void USART_TI(void) interrupt 4
{
while(RI == 1)
{
MAIN_BUF = SBUF;
RI = 0;
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询