《数显模数转换.doc》由会员分享,可在线阅读,更多相关《数显模数转换.doc(3页珍藏版)》请在金锄头文库上搜索。
1、#include#define uint unsigned intvoid delay(uint); unsigned char code dispcode=0xc0,0xcf,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x98;unsigned char code dispbitcode=0x10,0x20,0x40,0x80; extern unsigned char dispbuf6=0,0,0,0,0,0; unsigned char dispcount=0;unsigned int getdata;unsigned int temp,i;/unsigned
2、 char ;sbit ST=P30;sbit OE=P31;sbit EOC=P32;sbit CLK=P33;void main(void)ST=1;OE=1;TR0=0;TR1=0;TMOD=0x12;TH0=116;TL0=116;TH1=(65536-400)/256;TL1=(65536-400)%256;EA=1;ET0=1;ET1=1;TR1=1;TR0=1;ST=0;ST=1;while(1)if(EOC=1)OE=0;OE=1;temp=(uint)(5.00*getdata/256*100);/if(temp=0)temp*10;i=3;while(temp)dispbu
3、fi=temp%10;i-;temp=temp/10;dispbufi=temp;ST=0;delay(10);getdata=P0;ST=1;void t0(void) interrupt 1 CLK=CLK;void t1(void) interrupt 3 TH1=(65536-400)/256;TL1=(65536-400)%256;P1=dispcodedispbufdispcount|dispbitcodedispcount;/P2=;/if(dispcount=1)/P1=P1&0x7f;/dispcount+;if(dispcount=3)dispcount=0;if(P0=0x00)P1=0xc0; void delay(uint x) int i,j;for(i=0;ix;i+)for(j=1;j1000;j+);