⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 89s52.lst

📁 LCD1602.rar
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V6.12  89S52                                                                  08/20/2007 20:27:49 PAGE 1   


C51 COMPILER V6.12, COMPILATION OF MODULE 89S52
OBJECT MODULE PLACED IN 89S52.OBJ
COMPILER INVOKED BY: E:\Keil\C51\BIN\C51.EXE 89S52.c REGFILE(.\89S52.ORC) BROWSE ORDER FLOATFUZZY(0) DEBUG OBJECTEXTEND

stmt level    source

   1          #include<AT89x52.h>
   2          #include<stdio.h>
   3          #include <intrins.h>
   4          //端口定义
   5          sbit	LCDRS = P3^5;	
   6          sbit 	LCDRW = P3^6;	
   7          sbit 	LCDEN = P3^7;		
   8          sbit	LCDBF = P2^7;	
   9          
  10          #define	DBPORT  P2		
  11          #define DIS_CURS_OFF 0x0c
  12          #define LCD_CLRS 0x01
  13          #define DIS_HIDE 0x08		
  14          #define LCD_INIT 0x38	
  15          #define LCD_HOME 0x02
  16          #define LCD_DATA 1
  17          #define	LCD_COMMAND 0
  18          #define LCD_READ 1
  19          #define LCD_WRITE 0
  20          
  21          #define K1 6
  22          #define K2 5
  23          #define K3 4
  24          #define K4 3
  25          #define K5 2
  26          #define K6 1
  27          #define K7 0
  28          #define Fctrl	P0_3
  29          #define Tctrl	P0_4
  30          #define Distc	P0_5
  31          #define Width	P0_6
  32          #define	Cut		P0_7
  33          #define Stop	P1_6
  34          #define Clrs	P1_7
  35          #define Enex	P3_0
  36          #define Disall	P0=0xff;P1=0xff
  37          
  38          #define StopCount P1_6=0
  39          #define StarCount P1_6=1
  40          #define ClrsCount P1_7=0;_nop_();P1_7=1
  41          #define ClrsDff	  P1_2=0;_nop_();P1_2=1
  42          
  43          #define Backb	P1_3
  44          #define Backc	P1_4
  45          
  46          #define BackLight P1_0
  47          
  48          unsigned char sbuffer[15],w[5];
  49          unsigned char contrast=5;
  50          unsigned long value=0,copyer=0,wvalue=0;
  51          
  52          bit IsFreq=1;
  53          bit IsLow=1;
  54          
  55          void lcd_wait();
C51 COMPILER V6.12  89S52                                                                  08/20/2007 20:27:49 PAGE 2   

  56          void lcd_command(unsigned char command);
  57          void lcd_putchar(unsigned char character);
  58          void lcd_moveto(unsigned char x, unsigned char y);
  59          void lcd_print(unsigned char *str);
  60          void delay1s();
  61          void high_init();
  62          void key_delay();
  63          void key_jud();
  64          void low_init();
  65          void width_init();
  66          void depart_w();
  67          void intrT2();
  68          void width_get();
  69          void count();
  70          void count_init();
  71          void low_get();
  72          void show_high_t();
  73          void show_high_f();
  74          void show_low_t();
  75          void show_low_f();
  76          void intr0();
  77          void intr1();
  78          void high_get();
  79          void contrast_handle();
  80          void install();
  81          void lcd_init();
  82          
  83          void lcd_wait()
  84          {	
  85   1      	LCDEN=0;			   
  86   1      	DBPORT=0xff;		
  87   1      	LCDRS=LCD_COMMAND;	   
  88   1      	LCDRW=LCD_READ;
  89   1      	LCDEN=1;	_nop_();
  90   1      	while(LCDBF)
  91   1      	{	LCDEN=0;	_nop_();
  92   2      		LCDEN=1;	_nop_();
  93   2      	}
  94   1      	LCDEN=0;
  95   1      }  
  96          
  97          void lcd_command(unsigned char command)
  98          {	
  99   1      	lcd_wait();
 100   1      	LCDRS=LCD_COMMAND;
 101   1      	LCDRW=LCD_WRITE;		
 102   1      	DBPORT=command;		
 103   1      	LCDEN=1;	_nop_();				
 104   1      	LCDEN=0;
 105   1      }
 106          
 107          void lcd_putchar(unsigned char character)
 108          {	
 109   1      	lcd_wait();				 
 110   1      	LCDRS=LCD_DATA;
 111   1      	LCDRW=LCD_WRITE;		
 112   1      	DBPORT=character;		
 113   1      	LCDEN=1;	_nop_();				
 114   1      	LCDEN=0;
 115   1      }
 116          void lcd_moveto(unsigned char x, unsigned char y)
 117          {	
C51 COMPILER V6.12  89S52                                                                  08/20/2007 20:27:49 PAGE 3   

 118   1      	if(x==0)
 119   1      		lcd_command(0x80|y);
 120   1      	if(x==1)
 121   1      		lcd_command(0xc0|y);
 122   1      }
 123          		 
 124          void lcd_print(unsigned char *str)
 125          {	
 126   1      	while(*str!='\0')
 127   1      	{	lcd_putchar(*str);
 128   2      		str++;
 129   2      	}
 130   1      }
 131          
 132          void delay1s()
 133          {
 134   1      	unsigned char i,j,k;
 135   1      	for(i=0;i<255;i++)
 136   1      		for(j=0;j<103;j++)
 137   1      			for(k=0;k<11;k++);
 138   1      	for(k=0;k<216;k++);
 139   1      	_nop_();
 140   1      }
 141          
 142          void high_init()
 143          {
 144   1      	EA=0;
 145   1      	Disall;
 146   1      	Fctrl=0;	
 147   1      	TMOD=0x05;
 148   1      	TR0=1;
 149   1      	StopCount;
 150   1      	ClrsCount;
 151   1      	TL0=0;
 152   1      	TH0=0;
 153   1      }
 154          
 155          void key_delay()
 156          {
 157   1      	unsigned char i,j;
 158   1      	for(i=0;i<255;i++)
 159   1      		for(j=0;j<250;j++);
 160   1      }
 161          
 162          void key_jud()
 163          {
 164   1      	switch(P0&0x7)
 165   1      	{
 166   2      		case K6:TH0=0;
 167   2      			    TL0=0;
 168   2      			    ClrsCount;
 169   2      			    key_delay();							    
 170   2      				break;
 171   2      		case K7:P1_6=!P1_6;
 172   2      				lcd_moveto(1,15);
 173   2      				if(!P1_6) 
 174   2      					lcd_putchar('P');
 175   2      				else
 176   2      					lcd_putchar(' '); 	  
 177   2      				key_delay();
 178   2      				break;
 179   2      		case K1:w[0]++;
C51 COMPILER V6.12  89S52                                                                  08/20/2007 20:27:49 PAGE 4   

 180   2      				if(w[0]==10) w[0]=0;
 181   2      				key_delay();
 182   2      				break;
 183   2      		case K2:w[1]++;
 184   2      				key_delay();
 185   2      				if(w[1]==10) w[1]=0;
 186   2      				break;
 187   2      		case K3:w[2]++;
 188   2      				if(w[2]==10) w[2]=0;
 189   2      				key_delay();
 190   2      				break;
 191   2      		case K4:w[3]++;
 192   2      				if(w[3]==10) w[3]=0;
 193   2      				key_delay();
 194   2      				break;
 195   2      		case K5:w[4]++;
 196   2      				if(w[4]==10) w[4]=0;
 197   2      				key_delay();
 198   2      				break;				
 199   2      	}
 200   1      }
 201          
 202          void low_init()
 203          {
 204   1      	Disall;
 205   1      	Distc=0;
 206   1      	Tctrl=0;
 207   1      	Cut=0;
 208   1      	StopCount;
 209   1      	ClrsCount;
 210   1      	StarCount;
 211   1      	IsLow=1;
 212   1      	TL0=0;
 213   1      	TH0=0;
 214   1      	IT0=1;
 215   1      	IT1=1;
 216   1      	EX1=1;
 217   1      	EX0=1;
 218   1      	ClrsDff;
 219   1      	EA=1;
 220   1      }
 221          
 222          void width_init()
 223          {
 224   1      	Disall;
 225   1      	Width=0;
 226   1      	Tctrl=0;
 227   1      	ClrsCount;
 228   1      	TL0=0;
 229   1      	TH0=0;
 230   1      	TMOD=0x05;
 231   1      	TR0=1;
 232   1      	TF2=0;	
 233   1      	T2CON=8;
 234   1      	ET2=1;
 235   1      	ClrsCount;
 236   1      	TH0=0;
 237   1      	TL0=0;
 238   1          EA=1;
 239   1      }
 240          
 241          
C51 COMPILER V6.12  89S52                                                                  08/20/2007 20:27:49 PAGE 5   

 242          void depart_w()
 243          {
 244   1      	unsigned char i;
 245   1      	while(wvalue>=1e4) wvalue/=10;
 246   1      	for(i=0;i<4;i++)
 247   1      	{
 248   2      		w[3-i]=wvalue%10+'0';
 249   2      		wvalue/=10;
 250   2      	}
 251   1      }
 252          
 253          void intrT2() interrupt 5
 254          {
 255   1      	unsigned char i;
 256   1      	Tctrl=1;
 257   1      	P2=0xff;
 258   1      	Enex=0;
 259   1      	value=TH0;
 260   1      	value=(value<<8);
 261   1      	value=value+TL0;
 262   1      	value=(value<<8);
 263   1      	value=value+DBPORT;
 264   1      	Enex=1;
 265   1      	for(i=0;value;i++)
 266   1      	{
 267   2      		sbuffer[i]=value%10+'0';
 268   2      		value=value/10;
 269   2      	}
 270   1      	lcd_moveto(1,3);
 271   1      	i++;
 272   1      	while(i)
 273   1      	{
 274   2      		 lcd_putchar(sbuffer[i]);
 275   2      		 i--;
 276   2      	}
 277   1      	lcd_putchar(sbuffer[i]);
 278   1      	lcd_print(" uS          ");
 279   1      	while(1)
 280   1      	{
 281   2      		i=P0&0x07;
 282   2      		if(i==K1) break;
 283   2      	}
 284   1      	TH0=0;
 285   1      	TL0=0;
 286   1      	ClrsCount;
 287   1      	lcd_moveto(1,3);
 288   1      	lcd_print("  Capture.....");
 289   1      	key_delay();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -