《0809,1602设计数字报警电压表(按键调节报警电压值)》由会员分享,可在线阅读,更多相关《0809,1602设计数字报警电压表(按键调节报警电压值)(13页珍藏版)》请在金锄头文库上搜索。
1、icude re1.h#incudeitrins.h#dfnuchr usgnd char#fi unsn i h ,M,; uch ;t KEY3 =P3;sbit L =2;sbtLCD_RS =P26; sbit LCD_RW = P25;sbi LCD_E = P;uchrce dis1 CV:V;ha coe ds V:V;/089sbit SAR =P4;it EOC =P2;bit OE=P2;si LK=P21;charget=,l;uhar ian,,h,ge; odadc009() STR =; STRT =; START =0; hle(O=); O=1; getdt =
2、P1 ; =0; vo vl_resut() vol=gdat*500/55; voiddigsi()nerrt C; vshshihua() TOD=020;H=xfb; 1=0xf;T11; T=;EA=1; /延时函数vid dea(t m) uint ,TmpCyc; for(=0;im;i+) TepCc ; wil(Tepyc-); /测忙函数b lc_z() bitresut;LCDS 0;CD_ = 1;LCD_P = ;_nop_();_nop();op_();no_();lt = (bt)(P0 &0x0);LCD_E= 0;etr esult;/写指令void cd_wm
3、(intcd) while(lcdz());CD_ = ;LCD_R= ;LD_EP 0;_np_();_nop(); =cm;_nop_();_op_();np();p();CD_EP= 1;_nop_();_no_();_nop();op_();LC_EP ; P0 (cmd&0x0)4; _nop();no_(); _no();_nop_();LD_EP=;_o_();_np();_p_();_nop_();LCD_EP= 0; vo lcdpos(chr pos) cd_wcm(|x80);/*写数据函数*/vi ld_wt(chr da) ile(lcd());LCDRS = 1;L
4、_W0;LD_EP 0;0 da; op_();_nop_(); nop_();_np_();LCD_ ;_n();np_();no();_no();LD_E = 0; CD_S = 1;LCD_RW =;CD_E = ;o_();_nop();_np_();_np_();P0=(da&0f)0;p-) o(q=11;q0;-); o IT_int() EX0=; IT0=; EX1=1; T=1;EA=1; voddta_i(void) H=o0;M=o%0; void L_cou() f(KEY3=0) dl3(); if(Y3=0)f(L=9)L=0;lseL+; voi xanshi(
5、) dpos(044); lcd_wdt(di210);lcdat(is211);lcda(di21);ldwd(diH);ldwdat(s21);lcdwda(dis2);lcd_wdat(diL);ld_wt(dis24); /比较 vi cmp() i(aiH) ED=1; els (ba=H&hM) LD1; lse if(baiH&sh=M) if(ge) L=1; elseD=0; ele LED=; voidin()lcin();IN_ii();o=0;dschushi();whil(1)ad0809();vlt_rs();iash1(); data_in(); L_cout(); xini();cp();delay(10) ; oid it0()intert0 dela3(1); if(IT0=0) i(o=0) o=; ele +; void int1() nterrupt 2 dlay(10);if(IT=0) i(0) o=0; el -;