程序不知道怎么回事。,,设置p2=0X90,输出却是C0 C0 D0 D0 C0 D0 D0 C0 D0 D0
#include <reg51.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
uchar re_data[20];
uchar count=0;
uchar count1=0;
uchar i;
uchar j;
bit flag_1s=0;
void ser() interrupt 4
{
if(RI)
{ RI=0;
re_data[i++]=SBUF;
}
}
void timer0() interrupt 1 //定时器0中断子程序
{
TH0=0x4C; //赋初值50ms,作为基准值
TL0=0x00;
count++;
//if(count==40)
if(count==10)
{
count=0;
if(count1==8)
count1=0;
flag_1s=1;
count1++;
}
}
/*************串口初始化****************/
void serial_init()
{
SCON=0X50;
EA=1;
ES=0;
PS=1;
TH1=0XFD;
TL1=0XFD;
ET1=0;
TR1=1;
}
void chushihua(void)
{
TH0=0x4C; //赋初值50ms,作为基准值
TL0=0x00;
ET0=1;
TR0=1;
}
void Main()
{
TMOD=0x21;
serial_init();
chushihua();
P2=0X90;
while(1)
{
if(flag_1s==1)
{
TR0=0;
j=P2;
SBUF=j;
while(!TI);
TI=0;
flag_1s=0;
TR0=1;
}
}
} |