温度显示的程序之一.doc_第1页
温度显示的程序之一.doc_第2页
温度显示的程序之一.doc_第3页
温度显示的程序之一.doc_第4页
温度显示的程序之一.doc_第5页
已阅读5页,还剩4页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

/Function:Test Temperature.-30+105/Used Equation /RT/R25=e(B*(1/(T+273)-(1/298)/Change List:V0.9 - V0.91(07,02)/Change display A error/V0.91 - V0.92(07,03)/Add Temp Tab jiaozheng 70100C/*/#includeADUC812.h#includemath.h#includeintrins.h#includestring.h#includestdio.h#includedada.hbdata unsigned char LCD_data8; /* Display Buffer */intssdata3;#defineTemp_100235#defineTemp_401352sbits_data = P20; /* LCD Serial Data Port */sbit clk_lcd = P22; /* LCD Clock Port */sbit lcd_cs = P21; /* LCD Chip Select Port */sbitled=P27;/* LCD Command Name Define */#define cmd_off 0x00 /* LCD Control Power Down */#define cmd_on 0x01 /* LCD Control Power Up */#define cmd_LCD_off 0x02 /* Close LCD */#define cmd_LCD_on 0x03 /* Open LCD */#define cmd_LCD_B3C4 0x29 /* LCD Mode 1/3BAIS,1/4DUTY */#define cmd_LCD_RC 0x18 /* LCD Control Internal Oscillator 256K */data unsigned char Comm_buff16; /* Serial Port Receiver Buffer */data unsigned char Comm_len; /* Serial Port Receiver Data Length */bit Comm_ready; /* Serial Port Receiver Flag */* LCD Code 0,1,2.A,B,F,0.,1.,.A.,B.,F. */unsigned char code LCD_code = 0xeb,0x60,0xc7,0xe5,0x6c,0xad,0xaf,0xe0,0xef,0xed,0xee,0x2F,0x8b,0x67,0x8F,0x8e, 0xfb,0x70,0xd7,0xf5,0x7c,0xbd,0xbf,0xf0,0xff,0xfd,0xfe,0x3f,0x9b,0x77,0x9f,0x9e, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ; /* delay */void Delay(int p)/* Delay p Clock Cycle */int j;for(j=0;j=p;j+)_nop_();/* Delay N ms */void Delay_ms(int n)inti,j;for(i=0;i=n;i+)for(j=0;j=52;j+)/* Delay 1 ms */_nop_();/* LCD Data Display */void LCD_Display() unsigned char data i,j,k,tmp,tmp1,tmp2; /* Write Writr Mode Command Word 101 */lcd_cs = 0;/* Chip Select Enable */ Delay(100);clk_lcd = 0; /* Clock Down Edge */ s_data = 1;/* Data 1 */ clk_lcd = 1; /* Clock Up Edge */ clk_lcd = 0; /* Clock Down Edge */ s_data = 0;/* Data 0 */ clk_lcd = 1; /* Clock Up Edge */ clk_lcd = 0; /* Clock Down Edge */ s_data = 1;/* Data 1 */ clk_lcd = 1; /* Clock Up Edge */ s_data = 0; for(i=0; i6; i+) /* Write First Address 00000(A5-A0) */ clk_lcd = 0; /* Clock Down Edge */ s_data = 0;/* Data 0 */ clk_lcd = 1; /*Clock Up Edge */ for(i=0; i8; i+) /* 8 Bits Display Data */ k=8; tmp = LCD_datai; tmp1 = tmp&0xf0; /* High 4 Bits */ tmp2 = tmp&0x0f; /* Low 4 Bits */ /* Data Bits Write Out From M to L */ for(j=0; jk; j+) clk_lcd = 0; /* Clock Down Edge */if(tmp & 0x80) /* Data Out */ s_data = 1; else s_data = 0; clk_lcd = 1; /* Clock up Edge */ tmp = tmp 1; /* Data 1 Bit */ lcd_cs = 1; /* LCD Chip Select Disable *8/* LCD Command Write */void LCD_CMD(unsigned char cmd) unsigned char data i; /* Write Command Control Word 100 */ lcd_cs = 0;/* Chip Enable */ Delay(100); clk_lcd = 0; /* Clock Up Edge */ s_data = 1;/* Data 1 */ clk_lcd = 1; /* Clock Down Edge */ clk_lcd = 0; /* Clock Up Edge */ s_data = 0;/* Data 0 */ clk_lcd = 1; /* Clock Down Edge */ clk_lcd = 0; /* Clock Up Edge */ s_data = 0;/* Data 0 */ clk_lcd = 1; /* Clock Down Edge */ /* Write Command Word Bits From M to L,Add One Bit(hardware need) */ for(i=0; i9; i+) clk_lcd = 0; /* Clock Down Edge */ if(cmd & 0x80) s_data = 1; else s_data = 0;/* Data Write */ clk_lcd = 1; /* Clock Up Edge */ cmd = cmd 1; /* Command Data 1 Bit */ lcd_cs = 1; /* Chip Select disable */ /* Display */void Display(float TT)int con1=0,con2=0,con3=0,con4=0,con5=0,con6=0,dd=0,ss=0;long tt6;dd=TT*100;if(dd=5)con5=con5+1;if(con59)/* V0.9 - V0.91 chang dispaly A error */con5=0;con4=con4+1;if(con49)con4=0;con3=con3+1;if(con39)con3=0;con2=con2+1;if(con29)con2=0;con1=con1+1;/* V0.91 end */LCD_data7=/LCD_code;/* LCD Data */LCD_data6=LCD_codecon1;LCD_data5=LCD_codecon2;LCD_data4=LCD_codecon3+0x10;LCD_data3=LCD_codecon4;LCD_data2=LCD_codecon5;LCD_data1=0xcc;/LCD_codecom2;LCD_data0=0x8b;/LCD_codecom1;LCD_Display();/* Clear LCD */void Clear_LCD()LCD_data0 = 0x00; LCD_data1 = 0x00; LCD_data2 = 0x00; LCD_data3 = 0x00; LCD_data4 = 0x00; LCD_data5 = 0x00; LCD_data6 = 0x00; LCD_data7 = 0x00; LCD_data8 = 0x00; LCD_Display();/* LCD Inital */ void Inital_LCD(void) LCD_CMD(cmd_off); /* Close LCD System Oscillator */ LCD_CMD(cmd_LCD_off); /* Close LCD Bisa Control */ LCD_CMD(cmd_LCD_RC); /* Start internal RC Oscillator */ LCD_CMD(cmd_on); /* Open LCD System Oscillator */ LCD_CMD(cmd_LCD_on); /* Open LCD Bisa Control */ LCD_CMD(cmd_LCD_B3C4); /* Set Mode 1/3BAIS,1/4DUTY */ /* Serial Port set */void Inital_Serial(void)SCON=0x52;/* Serial Mode 1 */TMOD=0x21;/* T1 Mode 2 */TH1=0xFD;TL1=0xFD;/* Baud 9600 */TR1=1;/* Start T1 */TI=1;/* Open Int T1 */EA=1;/* Open All Int */* LCD Check */LCD_Check()inti;for(i=0;i4;if(Channel=0x01)Sum=0;for(i=0;i100;i+)Data=ADCDATAL|(ADCDATAH&0x0F) V0.92 ADD check Tab */if(Sum=Temp_100)for(i=0;i75;i+)if(Sum=ADC_Datai)j=i;Tem

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论