1602.LST
资源名称:RLC.rar [点击查看]
上传用户:jdm789308
上传日期:2020-12-22
资源大小:78k
文件大小:12k
源码类别:
软件测试
开发平台:
Visual C++
- C51 COMPILER V7.07 1602 08/24/2009 23:05:27 PAGE 1
- C51 COMPILER V7.07, COMPILATION OF MODULE 1602
- OBJECT MODULE PLACED IN 1602.OBJ
- COMPILER INVOKED BY: C:KeilC51BINC51.EXE 1602.c BROWSE DEBUG OBJECTEXTEND
- stmt level source
- 1 #include <reg52.h>
- 2 #include "1602.h"
- 3 #define DataPort P0
- 4 #define ADCPort P2
- 5 #define uchar unsigned char
- 6 sbit button_r=P1^0;
- 7 sbit button_c=P1^1;
- 8 sbit button_l=P1^2;
- 9 sbit button_q=P1^3;
- 10 sbit LED_R=P1^4;
- 11 sbit LED_C=P1^5;
- 12 sbit LED_L=P1^6;
- 13 sbit LED_Q=P1^7;
- 14 sbit RS=P3^0;
- 15 sbit RW=P3^1;
- 16 sbit EN=P3^2;
- 17 sbit START=P3^7;
- 18 unsigned char func;
- 19 unsigned long int R,C,L,f,y;
- 20 uchar i=0;
- 21 uchar aa,bb,cc;
- 22 //uchar code aa[5]="free";
- 23 uchar code meun[2][16]={" is: ","00000000 "};
- 24 uchar code m[10]="0123456789";
- 25 unsigned char T0count;
- 26 unsigned char timecount;
- 27 bit flag;
- 28 void Intar_T0T1(void)
- 29 {
- 30 1
- 31 1 flag=0;
- 32 1 timecount=0;
- 33 1 T0count=0;
- 34 1 TH0=0;
- 35 1 TL0=0;
- 36 1 TR0=1;
- 37 1 TR1=1;
- 38 1
- 39 1 }
- 40 void delay1(void)
- 41 {
- 42 1 int i;
- 43 1 for(i=80;i>0;i--);
- 44 1 }
- 45 void delay_ms(uchar t)
- 46 {
- 47 1 unsigned char i=0;
- 48 1 while(t--)for(i=0;i<120;i++);
- 49 1 }
- 50
- 51 void WriteData(uchar dat)
- 52 {
- 53 1 EN=0;
- 54 1 RS=0; //********RS寄存器选择输入端,当RS=0;当进行写模块操作,指向指令寄存器。
- 55 1 RW=0; //********当RS=1,无论是读操作还是写操作,都是指向数据寄存器。
- C51 COMPILER V7.07 1602 08/24/2009 23:05:27 PAGE 2
- 56 1 RS=1;
- 57 1 RW=0;
- 58 1 EN=1;
- 59 1 DataPort=dat;
- 60 1 EN=0;
- 61 1 RS=0;
- 62 1 RW=0;
- 63 1 for (i=0;i<20;i++);
- 64 1 }
- 65
- 66 void WriteCmd(uchar cmd)
- 67 {
- 68 1 EN=0;
- 69 1 RS=0; //********RS寄存器选择输入端,当RS=0;当进行写模块操作,指向指令寄存器。
- 70 1 RW=0; //********当RS=1,无论是读操作还是写操作,都是指向数据寄存器。
- 71 1 EN=1;
- 72 1 DataPort=cmd;
- 73 1 RS=0;
- 74 1 RW=0;
- 75 1 EN=0;
- 76 1 for (i=0;i<20;i++);
- 77 1 }
- 78
- 79 void DisChar(uchar ps,uchar dat)
- 80 {
- 81 1 WriteCmd((0x80+ps));
- 82 1 WriteData(dat);
- 83 1 }
- 84
- 85 void LcdInit(void)
- 86 {
- 87 1 char pp=0;
- 88 1
- 89 1 WriteCmd(0x38);
- 90 1 delay_ms(5);
- 91 1 WriteCmd(0x38);
- 92 1 delay_ms(5);
- 93 1 WriteCmd(0x38);
- 94 1 delay_ms(5);
- 95 1
- 96 1 WriteCmd(0x01);delay_ms(5);
- 97 1 WriteCmd(0x06);delay_ms(5);
- 98 1 WriteCmd(0x38);
- 99 1 WriteCmd(0x0c);
- 100 1 WriteCmd(0x40);
- 101 1
- 102 1 for(pp=0;pp<16;pp++)DisChar(pp,*(meun[0]+pp));
- 103 1 for(pp=0;pp<16;pp++)DisChar(pp+0x40,*(meun[1]+pp));
- 104 1 }
- 105
- 106 void Display(unsigned long int x)
- 107 { DisChar(0,aa);
- 108 1 DisChar(9+0x40,bb);
- 109 1 DisChar(10+0x40,cc);
- 110 1 DisChar(7+0x40,m[x%10]);x /= 10;
- 111 1 DisChar(6+0x40,m[x%10]);x /= 10;
- 112 1 DisChar(5+0x40,m[x%10]);x /= 10;
- 113 1 DisChar(4+0x40,m[x%10]);x /= 10;
- 114 1 DisChar(3+0x40,m[x%10]);x /= 10;
- 115 1 DisChar(2+0x40,m[x%10]);x /= 10;
- 116 1 DisChar(1+0x40,m[x%10]);x /= 10;
- 117 1 DisChar(0+0x40,m[x%10]);x /= 10;
- C51 COMPILER V7.07 1602 08/24/2009 23:05:27 PAGE 3
- 118 1 delay_ms(200);
- 119 1 }
- 120 button()
- 121 {
- 122 1 //button_r=1;
- 123 1 if(button_r==0)
- 124 1 {
- 125 2 func=1; //功能1:测电阻
- 126 2 LED_R=0;
- 127 2 LED_C=1;
- 128 2 LED_L=1;
- 129 2 LED_Q=1;
- 130 2 }
- 131 1 //button_c=1;
- 132 1 if(button_c==0)
- 133 1 {
- 134 2 func=2; //功能2:测电容
- 135 2 LED_R=1;
- 136 2 LED_C=0;
- 137 2 LED_L=1;
- 138 2 LED_Q=1;
- 139 2 }
- 140 1 //button_l=1;
- 141 1 if(button_l==0)
- 142 1 {
- 143 2 func=3; //功能3:测电感
- 144 2 LED_R=1;
- 145 2 LED_C=1;
- 146 2 LED_L=0;
- 147 2 LED_Q=1;
- 148 2 }
- 149 1 if(button_q==0)
- 150 1 {
- 151 2 func=4; //功能3:测电感
- 152 2 LED_R=1;
- 153 2 LED_C=1;
- 154 2 LED_L=1;
- 155 2 LED_Q=0;
- 156 2 }
- 157 1 return func;
- 158 1 }
- 159
- 160 void R_measure(void) //电阻测量,以Ω为单位
- 161 {
- 162 1 while(flag==0);
- 163 1 f=(T0count*65536+TH0*256+TL0); //Hz
- 164 1 //电阻计算公式
- 165 1 R=721500000/f-10000;
- 166 1 y=R;
- 167 1 }
- 168
- 169
- 170 void C_measure(void) //电容测量,以pF为单位
- 171 {
- 172 1 while(flag==0);
- 173 1 f=(T0count*65536+TH0*256+TL0); //Hz
- 174 1 //电容计算公式
- 175 1 C=4800000/f; //pf
- 176 1 y=C;
- 177 1 }
- 178
- 179 void L_measure(void) //电感测量,以uH为单位
- C51 COMPILER V7.07 1602 08/24/2009 23:05:27 PAGE 4
- 180 {
- 181 1 while(flag==0);
- 182 1 f=(T0count*65536+TH0*256+TL0); //Hz
- 183 1 //电感计算公式
- 184 1 f/=100000;
- 185 1 L=922/(f*f); //L=922*10^10/(f*f) uH
- 186 1 y=L;
- 187 1 }
- 188 unsigned int ADCTransform()
- 189 {
- 190 1 unsigned long int uiResult;
- 191 1 START=1;
- 192 1 START=0;
- 193 1 delay_ms(10);
- 194 1 uiResult=ADCPort; //出入转换结果。
- 195 1 uiResult=(10000000*uiResult)/51; //处理运算结果。
- 196 1 y=uiResult;
- 197 1 }
- *** WARNING C173 IN LINE 197 OF 1602.C: missing return-expression
- 198
- 199
- 200
- 201 void main(void)
- 202 { TMOD=0x15;//0001 0101
- 203 1 TH0=0;
- 204 1 TL0=0;
- 205 1 TH1=(65536-49989)/256;
- 206 1 TL1=(65536-49989)%256;
- 207 1 ET0=1;
- 208 1 ET1=1;
- 209 1 EA=1;
- 210 1 TR1=1;
- 211 1 TR0=1;
- 212 1 y=0x00;
- 213 1 //ADCPort=51;
- 214 1 LcdInit();
- 215 1 // while(1);
- 216 1 /*while(1)
- 217 1 {
- 218 1 if(flag==1)
- 219 1 {
- 220 1 y=(T0count*65536+TH0*256+TL0);
- 221 1 Display(y);
- 222 1 flag=0;
- 223 1 timecount=0;
- 224 1 T0count=0;
- 225 1 TH0=0;
- 226 1 TL0=0;
- 227 1 TR0=1;
- 228 1 TR1=1;
- 229 1
- 230 1 }
- 231 1 }*/
- 232 1 while(1)
- 233 1 {
- 234 2 button();
- 235 2 if (func==1)
- 236 2 {
- 237 3 aa='R';
- 238 3 bb='n';
- 239 3 cc='n';
- 240 3 R_measure();
- C51 COMPILER V7.07 1602 08/24/2009 23:05:27 PAGE 5
- 241 3
- 242 3 }
- 243 2 if (func==2)
- 244 2 {
- 245 3 aa='C';
- 246 3 bb='p';
- 247 3 cc='F';
- 248 3 C_measure();
- 249 3 }
- 250 2 if (func==3)
- 251 2 {
- 252 3 aa='L';
- 253 3 bb='u';
- 254 3 cc='H';
- 255 3 L_measure();
- 256 3 }
- 257 2 if(func==4)
- 258 2 {
- 259 3 aa='Q';
- 260 3 bb='n';
- 261 3 cc='n';
- 262 3 ADCTransform();
- 263 3 }
- 264 2 Display(y);
- 265 2 Intar_T0T1();
- 266 2 }
- 267 1 }
- 268
- 269 void t0(void) interrupt 1 using 0 //计脉冲个数
- 270 {
- 271 1 T0count++;
- 272 1 }
- 273
- 274 void t1(void) interrupt 3 using 0 //定时1s
- 275 {
- 276 1 TH1=(65536-50045)/256;
- 277 1 TL1=(65536-50045)%256;
- 278 1 timecount++;
- 279 1 if(timecount==20)
- 280 1 {
- 281 2 TR0=0;
- 282 2 TR1=0;
- 283 2 timecount=0;
- 284 2 flag=1;
- 285 2 }
- 286 1 }
- MODULE INFORMATION: STATIC OVERLAYABLE
- CODE SIZE = 1307 ----
- CONSTANT SIZE = 42 ----
- XDATA SIZE = ---- ----
- PDATA SIZE = ---- ----
- DATA SIZE = 27 8
- IDATA SIZE = ---- ----
- BIT SIZE = 1 ----
- END OF MODULE INFORMATION.
- C51 COMPILATION COMPLETE. 1 WARNING(S), 0 ERROR(S)