好文档 - 专业文书写作范文服务资料分享网站

2013年全国大学生电子设计竞赛A题论文

天下 分享 时间: 加入收藏 我要投稿 点赞

sbit AD_CLK=P1^3; sbit EOC=P1^4; sbit P3_0=P3^0;

void delay(unsigned int tt) {

while(tt--); }

void Write_Cmd(uchar dd) {

c_rs=0; c_rw=0; c_e=0; delay(50); P2=dd; c_e=1; delay(50); c_e=0; delay(50); }

void Write_Dat(uchar dd) {

c_rs=1; c_rw=0; c_e=0; delay(50); P2=dd; c_e=1; delay(50); c_e=0; delay(50); }

void Lcd_Init() { Write_Cmd(0x38); delay(200);

Write_Cmd(0x38); delay(200);

Write_Cmd(0x38); delay(200);

Write_Cmd(0x38); delay(200);

21

Write_Cmd(0x08); delay(200);

Write_Cmd(0x01); delay(200);

Write_Cmd(0x06); delay(200);

Write_Cmd(0x0c); delay(200);

Write_Cmd(0x80+0x00); }

uint tlc1543(uchar port) {

uint m=0; uint h; uchar i; AD_CS=0; EOC=1; port<<=4;

for(i=0;i<10;i++) { AD_IN=(bit)(port&0x80); AD_CLK=1; m<<=1;

h=AD_OUT; m=m|h; AD_CLK=0; port<<=1; }

EOC=0; AD_CS=1; return(m); }

void main() {

float res; uchar i=0; TCON=0x01; IP=0x01; IE=0x81; Lcd_Init(); while(1) {

22

if(xx==0) { num=tlc1543(0); res=num*5.0/1023.0; msg2[4]=msg1[(int)(res*1000)]; msg2[3]=msg1[(int)(res*100)]; msg2[1]=msg1[(int)(res*10)]; msg2[0]=msg1[(int)res]; if(msg2[0]==0x30) { msg2[1]=0x20; } Write_Cmd(0x80+0x02); Write_Dat(0x55); Write_Cmd(0x80+0x03); Write_Dat(0x3A); i=0; Write_Cmd(0x80+0x44); while(msg2[i]!=0x00) { Write_Dat(msg2[i]); i++; } Write_Cmd(0x80+0x50); Write_Dat(0x56); } if(xx==1) { num=tlc1543(1); res=num*5.0/1023.0/1.61; if(res<2.5) {P3_0=1;} if(res>=2.5) {P3_0=0;} msg3[4]=msg1[(int)(res*1000)]; msg3[3]=msg1[(int)(res*100)]; msg3[2]=msg1[(int)(res*10)]; msg3[0]=msg1[(int)res]; Write_Cmd(0x80+0x02); Write_Dat(0x49); Write_Cmd(0x80+0x03); 23

Write_Dat(0x3A); i=0; Write_Cmd(0x80+0x44); while(msg3[i]!=0x00) { Write_Dat(msg3[i]); i++; } Write_Cmd(0x80+0x50); Write_Dat(0x41); } if(xx==2) { num=tlc1543(2); res=num*5.0/1023.0/40.16; msg3[4]=msg1[(int)(res*1000)]; msg3[3]=msg1[(int)(res*100)]; msg3[2]=msg1[(int)(res*10)]; msg3[0]=msg1[(int)res]; Write_Cmd(0x80+0x02); Write_Dat(0xE0); Write_Cmd(0x80+0x03); Write_Dat(0x3A); i=0; Write_Cmd(0x80+0x44); while(msg3[i]!=0x00) { Write_Dat(msg3[i]); i++; } Write_Cmd(0x80+0x50); Write_Dat(0x20); } } }

void ISR_INT0() interrupt 0 using 1 {

xx++; if(xx==3) xx=0; }

24

2013年全国大学生电子设计竞赛A题论文

sbitAD_CLK=P1^3;sbitEOC=P1^4;sbitP3_0=P3^0;voiddelay(unsignedinttt){while(tt--);}voidWrite_Cmd(uchardd){c_rs=0;c_rw=0;c_e
推荐度:
点击下载文档文档为doc格式
762wx9wbwx9da6b52ivb
领取福利

微信扫码领取福利

微信扫码分享