|
大家好,我因为分不够所以只能在回复里面发一下求助了啊,是给STC系列单片机写的,主要是最终读的数据不对,不知道程序哪里出了错误谢谢
#include
#include
#define RELOAD_COUNT 0xfd //19200bps
void main ()
{ P1M1=0;
P1M0=0XFF;
//IT0=1; //INT0下降沿触发
//SCON = 0X50;
// BRT = RELOAD_COUNT;
AUXR = 0X11;
AUXR1 = 0X00;
// while(1)
{
TMOD=0x21;
EA=1;
EX0=1;
EX1=0;
TH1=0xe9;
TL1=0xe9;
TR1=1;
TH0=0;
TR0=0;
{ P1=0x02;
while(TF1!=1);
TF1=0;
TR1=0;
TL0=0;
// TMOD=0x01;
TR0=1;
P1=~P1;
}
}
}
void INT0_ (void) interrupt 0
{
//EA=0; //TR0=0;
unsigned int p=0;
unsigned int q=0;
unsigned int z=0;
unsigned int i=0;
char buff[10],a;
EA=0;
p=TH0,q=TL0;
// p=TH1,q=0X0;
z=(p/16)*16*16*16+(p%16)*16*16+(q/16)*16+q%16;
while(z>0)
{a=z%10+0x30;
buff=a;
i++;
z=z/10;
}
PCON=0x00; //SMOD=0;
SCON=0x40; //工作方式1 波特率9600 不允许接收
BRT=RELOAD_COUNT;
while(i>0)
{
SBUF=buff[i-1];
while(TI==0);
TI=0;
i--;
}
SBUF='\n';
while(TI==0);
TI=0;
EA=1;
} |
|