d.LST
上传用户:ypj0310
上传日期:2014-11-30
资源大小:71k
文件大小:10k
- C51 COMPILER V7.50 D 08/18/2007 20:13:13 PAGE 1
- C51 COMPILER V7.50, COMPILATION OF MODULE D
- OBJECT MODULE PLACED IN d.OBJ
- COMPILER INVOKED BY: D:keilC51BINC51.EXE d.c BROWSE DEBUG OBJECTEXTEND
- line level source
- 1 #include"reg51.h"
- 2 #include"intrins.h"
- 3 #include"math.h"
- 4 #include"absacc.h"
- 5 #define PORTA XBYTE[0x8500]
- 6 #define PORTB XBYTE[0x8502]
- 7 #define PORTC XBYTE[0x8504]
- 8 #define PORTC0 XBYTE[0x8506]
- 9 #define nop _nop_()
- 10 #define Right_RUN 1
- 11 #define Left_RUN 0
- 12 unsigned long RunSpeed=76;
- 13 unsigned char RUNState=1;
- 14 sbit RS=P2^0;
- 15 sbit RW=P2^1;
- 16 sbit E=P2^2;
- 17 sbit P17=P1^7;
- 18 bit flag=0;
- 19 unsigned char xx[]="speed(n/min):";
- 20 unsigned char SD[]="76";
- 21 char state[2][14]={"direction:cw","direction:ccw"};
- 22 unsigned char FLG,INMA=0;
- 23 unsigned char t,s=0x01;
- 24 unsigned int a;
- 25 main()
- 26 {
- 27 1 void OPJIAN();
- 28 1 unsigned char JIAN();
- 29 1 unsigned char JIANZHI();
- 30 1 void speed();
- 31 1 void SHOW_LCD();
- 32 1 void show_state();
- 33 1 void write1();
- 34 1 void writ2(unsigned char i);
- 35 1 void delay();
- 36 1 void time();
- 37 1 void busy();
- 38 1 unsigned char i;
- 39 1 i=0x90;
- 40 1 PORTC0=i;
- 41 1 i=0x01;
- 42 1 TMOD=i;
- 43 1 t=0x10;
- 44 1 a=0x0f;
- 45 1 TH0=0x10;
- 46 1 TL0=0x0f;
- 47 1 FLG=INMA;
- 48 1 SHOW_LCD();
- 49 1 show_state();
- 50 1 EA=1;
- 51 1 ET0=1;
- 52 1 TR0=1;
- 53 1 while(1)
- 54 1 {
- 55 2 i=JIAN();
- C51 COMPILER V7.50 D 08/18/2007 20:13:13 PAGE 2
- 56 2 if(i!=0)
- 57 2 {
- 58 3 time();
- 59 3 time();
- 60 3 }
- 61 2 i=JIAN();
- 62 2 if(i!=0)
- 63 2 {
- 64 3 INMA=JIANZHI();
- 65 3 OPJIAN();
- 66 3 time();
- 67 3 }
- 68 2 if(FLG!=INMA||flag==1)
- 69 2 { FLG=INMA;
- 70 3 SHOW_LCD();
- 71 3 show_state();
- 72 3 flag=0;
- 73 3 }
- 74 2 }
- 75 1 }
- 76 void SHOW_LCD()/*lcd设置程序*/
- 77 {
- 78 1 P1=0x38;
- 79 1 write1();
- 80 1 delay();
- 81 1 P1=0x38;
- 82 1 write1();
- 83 1 delay();
- 84 1 P1=0x38;
- 85 1 write1();
- 86 1 delay();
- 87 1 P1=0x01;
- 88 1 write1();
- 89 1 delay();
- 90 1 P1=0x0f;
- 91 1 write1();
- 92 1 delay();
- 93 1 P1=0x06;
- 94 1 write1();
- 95 1 delay();
- 96 1 P1=0x0c;
- 97 1 write1();
- 98 1
- 99 1 }
- 100 void show_state()/*状态显示程序*/
- 101 {
- 102 1 unsigned char i=0;
- 103 1 P1=0x80;
- 104 1 write1();
- 105 1 while(xx[i]!=' ')
- 106 1 {
- 107 2 writ2(xx[i]);
- 108 2 i++;
- 109 2 delay();
- 110 2 }
- 111 1 i=0;
- 112 1 while(SD[i]!=' ')
- 113 1 {
- 114 2 writ2(SD[i]);
- 115 2 delay();
- 116 2 i++;
- 117 2
- C51 COMPILER V7.50 D 08/18/2007 20:13:13 PAGE 3
- 118 2 }
- 119 1 P1=0xc0;
- 120 1 write1();
- 121 1 i=0;
- 122 1 if(RUNState==Right_RUN)
- 123 1 while(state[0][i]!=' ')
- 124 1 {
- 125 2 writ2(state[0][i]);
- 126 2 i++;
- 127 2 }
- 128 1 else
- 129 1 if(RUNState==Left_RUN)
- 130 1 while(state[1][i]!=' ')
- 131 1 {
- 132 2 writ2(state[1][i]);
- 133 2 i++;
- 134 2 }
- 135 1 }
- 136 void write1()/*lcd写控制字*/
- 137 {
- 138 1 RS=0;
- 139 1 RW=0;
- 140 1 E=0;
- 141 1 busy();
- 142 1 E=1;
- 143 1 }
- 144 void writ2( unsigned char i)/*lcd写数据*/
- 145 { P1=i;
- 146 1 RS=1;
- 147 1 RW=0;
- 148 1 E=0;
- 149 1 busy();
- 150 1 E=1;
- 151 1 }
- 152
- 153 void delay()/*延时程序*/
- 154 {
- 155 1 unsigned char i;
- 156 1 for(i=0;i<100;i++)
- 157 1 {
- 158 2 i=i;
- 159 2 }
- 160 1
- 161 1 }
- 162 void time()
- 163 { unsigned char i,j;
- 164 1 for(i=0;i<100;i++)
- 165 1 {
- 166 2 for(j=0;j<30;j++)
- 167 2 {
- 168 3 j=j;
- 169 3 }
- 170 2 }
- 171 1 }
- 172
- 173 void busy() //判断LCD是否忙
- 174 {
- 175 1 do
- 176 1 {
- 177 2 P1=0xff;
- 178 2 RS=0;
- 179 2 RW=1;
- C51 COMPILER V7.50 D 08/18/2007 20:13:13 PAGE 4
- 180 2 E=0;
- 181 2 nop;
- 182 2 E=1;
- 183 2 }while(P17==1);
- 184 1
- 185 1 }
- 186 unsigned char JIAN()/*判断是否有键按下*/
- 187 {
- 188 1 unsigned char i,j;
- 189 1 i=0xff;
- 190 1 PORTA=i;
- 191 1 time();
- 192 1 i=0x00;
- 193 1 PORTB=i;
- 194 1 j=PORTA;
- 195 1 j=~j;
- 196 1 j=j&(0x0f);
- 197 1 return j;
- 198 1 }
- 199 unsigned char JIANZHI()/*读键值程序*/
- 200 {
- 201 1 unsigned i,j,d,k,m=1;
- 202 1 i=0xfe;
- 203 1 k=0x01;
- 204 1 do
- 205 1 {
- 206 2 PORTB=i;
- 207 2 j=PORTA;
- 208 2 m=j&(0x01);
- 209 2 if(m==0)
- 210 2 d=k/2;
- 211 2 else
- 212 2 {
- 213 3 m=j&(0x02);
- 214 3 if(m==0)
- 215 3 d=k/2+4;
- 216 3 else
- 217 3 {
- 218 4 m=j&(0x04);
- 219 4 if(m==0)
- 220 4 d=k/2+8;
- 221 4 else
- 222 4 {
- 223 5 m=j&(0x08);
- 224 5 if(m==0)
- 225 5 d=k/2+12;
- 226 5 }
- 227 4 }
- 228 3 }
- 229 2 k=k+2;
- 230 2 i=i<<1;
- 231 2 i=i|(0x01);
- 232 2 }while(m!=0);
- 233 1 return d;
- 234 1 }
- 235 void OPJIAN() /* 键值处理程序*/
- 236 {
- 237 1 switch(INMA)
- 238 1 {
- 239 2 case 0x08: {RUNState=Right_RUN;s=0xf7;}break;
- 240 2 case 0x09: {RUNState=Left_RUN;s=0x01;}break;
- 241 2 case 0x0b: {
- C51 COMPILER V7.50 D 08/18/2007 20:13:13 PAGE 5
- 242 3 flag=1;
- 243 3 t=t-2;
- 244 3 RunSpeed=5000000/(65536-t*256-a);
- 245 3 speed();}break;
- 246 2 case 0x0f: {flag=1;
- 247 3 t=t+2;
- 248 3 RunSpeed=5000000/(65536-t*256-a);
- 249 3 speed();}
- 250 2 }
- 251 1 }
- 252 void speed()/*速度处理程序*/
- 253 {
- 254 1 unsigned char i=0;
- 255 1 SD[0]=RunSpeed/100+48;
- 256 1 SD[1]=RunSpeed%100/10+48;
- 257 1 SD[2]=RunSpeed%10+48;
- 258 1 }
- 259 void time1(void) interrupt 1 using 2
- 260 {
- 261 1
- 262 1 TR0=0;
- 263 1 PORTC=s;
- 264 1 if(RUNState==0)
- 265 1 {
- 266 2 s=(s<<1);
- 267 2 if(s==0x10)
- 268 2 s=0x01;
- 269 2
- 270 2 }
- 271 1 else
- 272 1 {
- 273 2 s=s>>1;
- 274 2 if(s==0x0f)
- 275 2 s=0xf7;
- 276 2 }
- 277 1 TH0=t;
- 278 1 TL0=a;
- 279 1 TR0=1;
- 280 1 }
- 281
- 282
- 283
- MODULE INFORMATION: STATIC OVERLAYABLE
- CODE SIZE = 748 ----
- CONSTANT SIZE = ---- ----
- XDATA SIZE = ---- ----
- PDATA SIZE = ---- ----
- DATA SIZE = 56 7
- IDATA SIZE = ---- ----
- BIT SIZE = 1 ----
- END OF MODULE INFORMATION.
- C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)