欢迎来到天天文库
浏览记录
ID:59121206
大小:41.50 KB
页数:14页
时间:2020-09-13
《设计数字报警电压表(按键调节报警电压值).doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、......#include#include#defineucharunsignedchar#defineuintunsignedintucharH,M,L;ucharo;sbitKEY3=P3^5;sbitLED=P2^0;sbitLCD_RS=P2^6;sbitLCD_RW=P2^5;sbitLCD_EP=P2^7;ucharcodedis1[]={"0123456789CV:.V"};ucharcodedis2[]={"0123456789WV:.V"};//0809sbitSTART=P2^4;sbitE
2、OC=P2^3;sbitOE=P2^2;sbitCLK=P2^1;uchargetdata=0,volt;ucharqian,bai,shi,ge;voidadc0809(){....v......START=0;START=1;START=0;while(EOC==0);OE=1;getdata=P1;OE=0;}voidvolt_result(){volt=getdata*500/255;}voiddingshi()interrupt3{CLK=~CLK;}voiddschushihua(){TMOD=0x20;TH1=0xfb;TL1=0xfb;
3、TR1=1;....v......ET1=1;EA=1;}//延时函数voiddelay(intms){uinti,TempCyc;for(i=0;i4、md){while(lcd_bz());LCD_RS=0;LCD_RW=0;LCD_EP=0;_nop_();_nop_();P0=cmd;_nop_();_nop_();_nop_();....v......_nop_();LCD_EP=1;_nop_();_nop_();_nop_();_nop_();LCD_EP=0;P0=(cmd&0x0f)<<4;_nop_();_nop_();_nop_();_nop_();LCD_EP=1;_nop_();_nop_();_nop_();_nop_();LCD_EP=0;}voidlcd_pos(ucha5、rpos){....v......lcd_wcmd(pos6、0x80);}/****************写数据函数************************/voidlcd_wdat(uchardat){while(lcd_bz());LCD_RS=1;LCD_RW=0;LCD_EP=0;P0=dat;_nop_();_nop_();_nop_();_nop_();LCD_EP=1;_nop_();_nop_();_nop_();_nop_();LCD_EP=0;....v......LCD_RS=1;LCD_RW=0;LCD_EP=0;_n7、op_();_nop_();_nop_();_nop_();P0=(dat&0x0f)<<4;_nop_();_nop_();_nop_();_nop_();LCD_EP=1;_nop_();_nop_();_nop_();_nop_();LCD_EP=0;}voidlcd_init(){....v......lcd_wcmd(0x38);delay(5);lcd_wcmd(0x0c);delay(5);lcd_wcmd(0x02);delay(5);lcd_wcmd(0x01);delay(100);}voidxianshi1(){lcd_pos(48、);bai=(volt*2)/100;shi=(volt*2)%100/10;ge=(volt*2)%10;lcd_wdat(dis1[10]);lcd_wdat(dis1[11]);lcd_wdat(dis1[12]);lcd_wdat(dis1[bai]);lcd_wdat(dis1[13]);lcd_wdat(dis1[shi]);lcd_wdat(dis1[ge]);....v......lcd_wdat(dis1[14]);}//按键中断voiddelay3(uintk){uintp,q;for(p=k;p>0;p--){for(q=110;9、q>0;q--);}}voidINT_init(){EX0=1;IT0=1;EX1=1;IT1
4、md){while(lcd_bz());LCD_RS=0;LCD_RW=0;LCD_EP=0;_nop_();_nop_();P0=cmd;_nop_();_nop_();_nop_();....v......_nop_();LCD_EP=1;_nop_();_nop_();_nop_();_nop_();LCD_EP=0;P0=(cmd&0x0f)<<4;_nop_();_nop_();_nop_();_nop_();LCD_EP=1;_nop_();_nop_();_nop_();_nop_();LCD_EP=0;}voidlcd_pos(ucha
5、rpos){....v......lcd_wcmd(pos
6、0x80);}/****************写数据函数************************/voidlcd_wdat(uchardat){while(lcd_bz());LCD_RS=1;LCD_RW=0;LCD_EP=0;P0=dat;_nop_();_nop_();_nop_();_nop_();LCD_EP=1;_nop_();_nop_();_nop_();_nop_();LCD_EP=0;....v......LCD_RS=1;LCD_RW=0;LCD_EP=0;_n
7、op_();_nop_();_nop_();_nop_();P0=(dat&0x0f)<<4;_nop_();_nop_();_nop_();_nop_();LCD_EP=1;_nop_();_nop_();_nop_();_nop_();LCD_EP=0;}voidlcd_init(){....v......lcd_wcmd(0x38);delay(5);lcd_wcmd(0x0c);delay(5);lcd_wcmd(0x02);delay(5);lcd_wcmd(0x01);delay(100);}voidxianshi1(){lcd_pos(4
8、);bai=(volt*2)/100;shi=(volt*2)%100/10;ge=(volt*2)%10;lcd_wdat(dis1[10]);lcd_wdat(dis1[11]);lcd_wdat(dis1[12]);lcd_wdat(dis1[bai]);lcd_wdat(dis1[13]);lcd_wdat(dis1[shi]);lcd_wdat(dis1[ge]);....v......lcd_wdat(dis1[14]);}//按键中断voiddelay3(uintk){uintp,q;for(p=k;p>0;p--){for(q=110;
9、q>0;q--);}}voidINT_init(){EX0=1;IT0=1;EX1=1;IT1
此文档下载收益归作者所有