资源描述:
《LM016L的显示程序》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、#include#include#defineucharunsignedchar#defineuint unsignedintsbitDQ=P2^7; //定义DS18B20端口DQ voidreset(); //DS18B20复位函数 voidwrite_byte(ucharval); //DS18B20写命令函数 ucharread_byte(void); //DS18B20读1字节函数
2、voidread_temp(); //温度读取函数 voidwork_temp(); //温度数据处理函数 sbitBEEP=P2^5; //蜂鸣器驱动线 bitpresence ;sbitLCD_RS=P3^5; sbitLCD_RW=P3^6;sbitLCD_EN=P3^7;ucharcode cdis1[]={" SETTEMP: 50.C "};ucharcode cdis2[]={" TESTTEMP
3、: . C"};ucharcode cdis3[]={"DS18B20 ERR0R"};ucharcode cdis4[]={" PLEASECHECK "};unsignedchardata temp_data[2]={0x00,0x00};unsignedchardata display[5]= {0x00,0x00,0x00,0x00,0x00};unsignedcharcode ditab[16]= {0x00,0x01,0x01,0x02,0x03,0x03,0x04,0x05,0x06,0x06,0x07,0x08,0x
4、08,0x09,0x09};voidbeep();unsignedcharcode mytab[8]={0x0C,0x12,0x12,0x0C,0x00,0x00,0x00,0x00};#definedelayNOP();{_nop_();_nop_();_nop_();_nop_();};/*******************************************************************/voiddelay1(intms){unsignedchary; while(ms--){ for(y=0;y<250;y++) {
5、 _nop_(); _nop_(); _nop_(); _nop_(); }}}/******************************************************************//*检查LCD忙状态 *//*lcd_busy为1时,忙,等待。lcd-busy为0时,闲,可写指令与数据。 *//**********************************************************
6、********/bitlcd_busy(){ bitresult; LCD_RS=0; LCD_RW=1; LCD_EN=1; delayNOP(); result=(bit)(P1&0x80); LCD_EN=0; return(result);}/*写指令数据到LCD *//*RS=L,RW=L,E=高脉冲,D0-D7=指令码。 *//******
7、*************************************************************/voidlcd_wcmd(ucharcmd){ while(lcd_busy()); LCD_RS=0; LCD_RW=0; LCD_EN=0; _nop_(); _nop_(); P1=cmd; delayNOP(); LCD_EN=1; delayNOP(); LCD_EN=0; }/*********************
8、*****