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

📄 motor.lst

📁 用C写的步进电机程序
💻 LST
字号:
C51 COMPILER V7.04   MOTOR                                                                 10/25/2007 18:49:27 PAGE 1   


C51 COMPILER V7.04, COMPILATION OF MODULE MOTOR
OBJECT MODULE PLACED IN motor.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE motor.c BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1          #include<reg52.h>
   2          
   3          #define BYTE unsigned char   
   4          BYTE    count;                                  // 1 cycle pace counter
   5          BYTE    pace;                                   // motor control counter
   6          unsigned char bdata Flag _at_ 0x25;
   7          sbit    Fdir=Flag^0;                    //Fdir=1  positive running  =0 negative running
   8          sbit    Fdir1=Flag^1;                   //Fdir=1  positive running  =0 negative running
   9          sbit    Fstop=Flag^4;                   //Fstop=1 stop:50us-100us-0(stop)  =0start:0-100us-50us(running)
  10          
  11          unsigned char code TAB[]={06,04,05,01,03,02,06,02,03,01,05,04};
  12          
  13          void timer1() interrupt 3 using 1
  14          {
  15   1      ACC=6-pace;                                             // get offset  address
  16   1      if(Fdir1==0)ACC=ACC+6;                          // judge it's negative running or not 
  17   1      P1=ACC=TAB[ACC];                                        // get MOTOR ouput data   =0 then running 
  18   1      if(--pace==0)pace=6;                    // 3 phase 6 pace over then reload
  19   1      if(--count!=0)return;                   // control over or not then exit 
  20   1        else {
  21   2                      count=12;                               // reload count
  22   2                      Fdir1=Fdir;                             // get direction 
  23   2                      if(Fstop==0)                    // if want to stop then skip
  24   2                        {if(TH1>205)return;   // if self cycle = 50us then normal running and exit
  25   3                           else TH1=TH1+5;    // else cycle-5us
  26   3                        }
  27   2                      else 
  28   2                              {if(TH1<157)            // if self cycle = 100us then stop and exit
  29   3                                      {Fstop=1;TR1=0;TH1=156;return;}
  30   3                              else TH1=TH1-5;         // else cycle+5us
  31   3                              }
  32   2                 }
  33   1      }
  34          
  35          void main(void )
  36          {TMOD=0X20;
  37   1      P1=0x00;
  38   1      P2=0x00;
  39   1      P0=0x00;
  40   1      P3=0x00;
  41   1      count=12;
  42   1      pace=6;
  43   1      TL1=156;TH1=156;        
  44   1      Fdir=Fdir1=Fstop=1;
  45   1      EA=ET1=TR1=1;
  46   1      Fstop=0;
  47   1      do{}while(1);
  48   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    130    ----
   CONSTANT SIZE    =     12    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
C51 COMPILER V7.04   MOTOR                                                                 10/25/2007 18:49:27 PAGE 2   

   DATA SIZE        =      2    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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