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

📄 motor.lst

📁 keil c 文件 @@##%%…… &……源代码程序
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V7.06   MOTOR                                                                 09/13/2005 19:28:53 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE MOTOR
OBJECT MODULE PLACED IN .\img\motor.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE motor.c BROWSE DEBUG OBJECTEXTEND OBJECT(.\img\motor.obj)

stmt level    source

   1          #include <reg52.h>
   2          #include<absacc.h>
   3          #include <intrins.h>
   4          #include <math.h>
   5          
   6          #include <stdio.h>                /* prototype declarations for I/O functions */
   7          
   8          
   9                  
  10          sbit cflag=ACC^7;
  11          
  12          sbit L297_L_CW=P1^0;
  13          sbit L297_L_CLK=P1^1;
  14          sbit L297_L_HALF=P1^2;
  15          sbit L297_L_RST=P1^3;
  16          sbit L297_L_CTL=P1^4;
  17          sbit L297_L_EN=P1^5;
  18          
  19          sbit L297_R_CW=P1^6;
  20          sbit L297_R_CLK=P1^7;
  21          sbit L297_R_HALF=P3^0;
  22          sbit L297_R_RST=P3^1;
  23          sbit L297_R_CTL=P3^2;
  24          sbit L297_R_EN=P3^4;
  25          
  26          
  27          
  28          #define uchar unsigned char
  29          #define uint unsigned int
  30          
  31          #define STEP 26
  32          
  33          #define SPEED 5
  34          
  35          #define ctrl8279 XBYTE[0X0100]
  36          #define data8279 XBYTE[0X0000]
  37          
  38          
  39          
  40          
  41          
  42              uchar x0,y0;
  43              unsigned int i,j;
  44              uchar k,eol;
  45              float mmx,mmy;
  46                  float mx,my;
  47                  int cr=25;
  48                  int cx0=40,cy0=50;
  49          
  50          
  51          /*********************************/
  52          
  53          void msec(unsigned int x){
  54   1      uchar j;
  55   1      while(x--){
C51 COMPILER V7.06   MOTOR                                                                 09/13/2005 19:28:53 PAGE 2   

  56   2      for(j=0;j<125;j++)
  57   2      {;}
  58   2      }
  59   1      }
  60          
  61          /*************************/
  62          uchar code table[]={0x0fc,0x60,0x0da,0x0f2,0x66,0x0b6,0x0be,0x0e0,0x0fe,0x0f6,0x8e,0x02};
  63          /****************************/
  64          void wdat_8279(uchar d){
  65   1      msec(1);
  66   1      do
  67   1      {ACC=ctrl8279;}
  68   1      while (cflag==1);
  69   1      data8279=d;
  70   1      }
  71          
  72          
  73          /*******************************************/
  74          
  75          void wcom_8279(uchar c){
  76   1      msec(1);
  77   1      do
  78   1      {ACC=ctrl8279;}
  79   1      while (cflag==1);
  80   1      ctrl8279=c;
  81   1      }
  82          /********************/
  83          
  84          void init8279()
  85          {
  86   1        //unsigned char i;
  87   1       ctrl8279=0x32;            //biancheng minglin shizhong :ale 18 fenping 00110010
  88   1       ctrl8279=0x00;            //8zifuxianshi you ru kou ,bianma sao miao jianpan,shuang jian suo
  89   1       ctrl8279=0xd0;            //xianshi ram qing 0,quan zhi 1;
  90   1       
  91   1      
  92   1       }
  93           /******************/
  94          
  95          
  96          
  97          void display_xy(int x, int y , uchar ch){
  98   1          
  99   1          if (y<1) y=1;
 100   1          if (y>2) y=2;
 101   1          if (x<1) x=1;
 102   1          if (x>4) x=4;
 103   1          if (ch<0) ch=0;
 104   1          if (ch>15) ch=15;
 105   1          if (y==1) {
 106   2            switch (x) {
 107   3             case 1:  wcom_8279(0x87);      
 108   3                      wdat_8279(table[ch]);
 109   3                                      break;
 110   3             case 2:  wcom_8279(0x83);      
 111   3                      wdat_8279(table[ch]);
 112   3                              break;
 113   3             case 3:  wcom_8279(0x85);      
 114   3                      wdat_8279(table[ch]);
 115   3                                      break;
 116   3             case 4:  wcom_8279(0x81);      
 117   3                      wdat_8279(table[ch]);
C51 COMPILER V7.06   MOTOR                                                                 09/13/2005 19:28:53 PAGE 3   

 118   3                              break;
 119   3            } 
 120   2            
 121   2          }else {
 122   2                 switch (x) {
 123   3             case 1:  wcom_8279(0x86);      
 124   3                      wdat_8279(table[ch]);
 125   3                                      break;
 126   3             case 2:  wcom_8279(0x82);      
 127   3                      wdat_8279(table[ch]);
 128   3                              break;
 129   3             case 3:  wcom_8279(0x84);      
 130   3                      wdat_8279(table[ch]);
 131   3                                      break;
 132   3             case 4:  wcom_8279(0x80);      
 133   3                      wdat_8279(table[ch]);
 134   3                              break;
 135   3            } 
 136   2            
 137   2          }
 138   1      
 139   1      }
 140          
 141          
 142          
 143          void display2( int k){
 144   1      
 145   1          uint s=0,a=0,d=0, m=0,f=0,n=0,i;
 146   1      
 147   1              
 148   1              uint neg=0;
 149   1               
 150   1              if(k>-999&&k<=9999)
 151   1           { 
 152   2           // ctrl8279=0x00;
 153   2                   if (k<0) {
 154   3                         k=-k;
 155   3                         neg=1;
 156   3                       }
 157   2               s=k/1000;
 158   2               wcom_8279(0x86);      
 159   2               wdat_8279(table[s]);
 160   2      
 161   2               a=k%1000;
 162   2               d=a/100;
 163   2               wcom_8279(0x82); 
 164   2               i=0x80;
 165   2                wdat_8279(table[d]);
 166   2                //
 167   2               m=a%100;
 168   2               f=m/10;
 169   2               wcom_8279(0x84);
 170   2              i=0x80;
 171   2               wdat_8279(table[f]);
 172   2              
 173   2               n=m%10;
 174   2               
 175   2              wcom_8279(0x80);
 176   2              wdat_8279(table[n]);  
 177   2          }
 178   1             if (neg) display_xy(1,2,11);
 179   1      
C51 COMPILER V7.06   MOTOR                                                                 09/13/2005 19:28:53 PAGE 4   

 180   1      }
 181          void display1( int k)
 182          { 
 183   1          uint s=0,a=0,d=0, m=0,f=0,n=0,i;
 184   1      
 185   1              uint neg=0;
 186   1               
 187   1              if(k>-999&&k<=9999)
 188   1           { 
 189   2           // ctrl8279=0x00;
 190   2                   if (k<0) {
 191   3                         k=-k;
 192   3                         neg=1;
 193   3                       }
 194   2               s=k/1000;
 195   2               wcom_8279(0x87);      
 196   2               wdat_8279(table[s]);
 197   2      
 198   2               a=k%1000;
 199   2               d=a/100;
 200   2               wcom_8279(0x83); 
 201   2               i=0x80;
 202   2                wdat_8279(table[d]);
 203   2                //
 204   2               m=a%100;
 205   2               f=m/10;
 206   2               wcom_8279(0x85);
 207   2              i=0x80;
 208   2               wdat_8279(table[f]);
 209   2              
 210   2               n=m%10;
 211   2               
 212   2              wcom_8279(0x81);
 213   2             wdat_8279(table[n]);
 214   2             //
 215   2             }
 216   1            if (neg) display_xy(1,1,11);
 217   1                 
 218   1       }  
 219           /***********************/
 220          
 221           uchar key_pressed(void) //判断FIFO有键按下函数
 222          {uchar k;
 223   1      k=ctrl8279;
 224   1      return(k&0x0f); //非0,有键按下
 225   1      }
 226          
 227          
 228          uchar keyin(void)
 229          {uchar i,k;
 230   1      while(key_pressed()==0);
 231   1      wcom_8279(0x40); //读FIFO RAM命令
 232   1      i=data8279;
 233   1      k=0;
 234   1      switch(i)
 235   1           {
 236   2                case 196:
 237   2                display1(0);
 238   2                        k=0;
 239   2                break;
 240   2                case 228:
 241   2                display1(1);
C51 COMPILER V7.06   MOTOR                                                                 09/13/2005 19:28:53 PAGE 5   

 242   2                        k=1;
 243   2                break;
 244   2                case 192:
 245   2                display1(2);
 246   2                        k=2;
 247   2                break;
 248   2                case 224:
 249   2                display1(3);
 250   2                        k=3;
 251   2                break;
 252   2                case 197:
 253   2                display1(4);
 254   2                        k=4;
 255   2                break;
 256   2                case 229:
 257   2                display1(5);
 258   2                        k=5;
 259   2                break;
 260   2                case 193:
 261   2                display1(6);
 262   2                        k=6;
 263   2                break;
 264   2                case 225:
 265   2                display1(7);
 266   2                        k=7;
 267   2                break;
 268   2                case 198:
 269   2                display1(8);
 270   2                        k=8;
 271   2                break;
 272   2                case 230:
 273   2                display1(9);
 274   2                         k=9;
 275   2                break;
 276   2                case 194:
 277   2                display1(10);
 278   2                       k=10;
 279   2                break;
 280   2                case 226:
 281   2                display1(11);
 282   2                       k=11;
 283   2                break;
 284   2                case 199:
 285   2                display1(12);
 286   2                       k=12;
 287   2                break;
 288   2                case 231:
 289   2                display1(13);
 290   2                        k=13;
 291   2                break;
 292   2                case 195:
 293   2                display1(14);
 294   2                       k=14;
 295   2                break;
 296   2                case 227:
 297   2                display1(15);
 298   2                        k=15;
 299   2                break;  
 300   2              }
 301   1      
 302   1      return(k);
 303   1      
C51 COMPILER V7.06   MOTOR                                                                 09/13/2005 19:28:53 PAGE 6   

 304   1      }
 305           /**************************/
 306          
 307          
 308          
 309          
 310          void Rmotor(float L){
 311   1       int i,j;
 312   1          if (L<0){
 313   2          L297_L_CW=1;
 314   2              }else {
 315   2              L297_L_CW=0;
 316   2              }
 317   1          j=abs(STEP*L);
 318   1          for (i=0;i<j;i++){
 319   2           L297_L_CLK=0;
 320   2               msec(SPEED);
 321   2               L297_L_CLK=1;
 322   2               msec(SPEED);
 323   2              }
 324   1      

⌨️ 快捷键说明

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