|
uchar dispc[2][16]=
{
' ','0','O','O','T','P','U','T',' ','P','O','W','E','R',' ',' ',
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','d','B','m',' ',' ',' '
};
code unsigned char ctab[19]={'0','1','2','3','4','5','6','7','8','9','a','b','c','d','<','>','L','O','W'};
void displcd(void){ //LCD1602
uint i;
RW=0;
_nop_();
le1=Ddram_Al1;
Delay(200);
for (i=0;i<16;i++)
{
le2=dispc[0];
Delay(200);
}
le1=Ddram_Al2;
Delay(20);
for (i=0;i<16;i++)
{
le2=dispc[1];
Delay(20);
// 写字符
}
//le2='0';
// 写字符
RW=1;
}
void main(void)
{
//以下设置中断和定时器;
EA=1; PT0=1;
ET0=1;
IT0=1;IT1=1;
EX0=1;EX1=1;
TCON=0x08;
TMOD=0x21;
//定时器0为产生1ms的中断,定时器1为9600b/s的波特率发生器;
TH0=-1000/256;
TL0=-1000%256;
TL1=0xfd;
TH1=0xfd;
SCON=0x50;
PCON=0x80;
//开定时器
TR1=1;
TR0=1;
TI=1;
while(1){}
}
void intsvr1(void) interrupt 1 //ADC0809
{
uchar A,co;
uchar B;
uchar C;
uchar D;
//重新装入定时器0的初值;
TH0=-10000/256;
TL0=-10000%256;
FREQ=FREQ+1;
if(FREQ==100)
{
FREQ=0;
SBUF=AD0;
A = SBUF/1000;
B = SBUF%1000/100;
C = SBUF%1000%100/10;
D = SBUF%1000%100%10;
co=A*1000+B*100+C*10+D;
dispc[1][1] =ctab[B];
dispc[1][2] =ctab[C];
dispc[1][3] =ctab[D];
displcd();
}
}
|
|