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

📄 x051.lst

📁 VB写的上位机
💻 LST
字号:
C51 COMPILER V7.10   X051                                                                  06/24/2005 03:20:11 PAGE 1   


C51 COMPILER V7.10, COMPILATION OF MODULE X051
OBJECT MODULE PLACED IN x051.OBJ
COMPILER INVOKED BY: D:\Program Files\Keil\C51\BIN\C51.EXE x051.c BROWSE DEBUG OBJECTEXTEND

line level    source

   1          #include <reg51.h> 
   2          #include <stdio.h>
   3          
   4          unsigned i;
   5          unsigned Sectors,Codes;
   6          unsigned Allcodes;
   7          unsigned Signature[2]={0,0};
   8          char Command;
   9          
  10          #define DATA P1
  11          
  12          sbit Prog = P3^3;               //Address Advanced Pulse (positive)     Always Low
  13          sbit Addr = P3^2;               //Program Pulse (minus)                                 Always High
  14          sbit Busy = P3^4;               //Ready or Busy (Low)                                   Always High
  15          sbit OE = P3^7;                 //Control Signal Output Enable  (Low)   Always High
  16          sbit EData = P3^5;              //Control Signal Lock (Low)                             Always Low
  17          sbit ARST = P1^4;
  18          
  19          unsigned Getchar();
  20          void Connect();
  21          void ReadSignature();
  22          void SetType();
  23          void SetMcuType();
  24          void Erase();
  25          void Write();
  26          void Read();
  27          void Lock();
  28          
  29          void main()
  30          {
  31   1              Addr=0;
  32   1              Prog=Busy=OE=EData=1;
  33   1              SCON = 0x52;                                    // 8-bit UART mode
  34   1              PCON = 0x80;
  35   1              TMOD = 0x20;                                    // timer 1 mode 2 auto reload
  36   1              TH1 = 0xff;                                     // 57600 8 n 1
  37   1              TR1 = 1;                                                // run timer1
  38   1              while(1)
  39   1              {
  40   2                      Command=(char)(Getchar());
  41   2              Connect();
  42   2                      ReadSignature();
  43   2                      SetMcuType();
  44   2              Erase();
  45   2              Write();
  46   2              Read();
  47   2              Lock();
  48   2          }
  49   1      }
  50          
  51          void Putchar(char c)
  52          {
  53   1              while(!TI);
  54   1              TI=0;
  55   1              SBUF=c;
C51 COMPILER V7.10   X051                                                                  06/24/2005 03:20:11 PAGE 2   

  56   1      }
  57          
  58          unsigned Getchar()
  59          {
  60   1              while(!RI);
  61   1              RI=0;
  62   1              return SBUF;
  63   1      }
  64          
  65          void Delay1us(int n)
  66          {
  67   1          int i;
  68   1          for(i=0;i<n;i++);
  69   1      }
  70          
  71          void Delay1ms(int n)
  72          {
  73   1          int i;
  74   1          for(i=0;i<n;i++)
  75   1          Delay1us(1000);
  76   1      }
  77          
  78          void Connect()
  79          {
  80   1              if (Command=='C') Putchar('C');
  81   1      }
  82          
  83          void SetType()
  84          {
  85   1              switch(Signature[1])
  86   1              {
  87   2                      case 0x11:                                                      //AT89C1051
  88   2                      case 0x12: Allcodes=1024;break;         //AT89C1051U
  89   2                      case 0x21:                                                      //AT89C2051
  90   2                      case 0x22: Allcodes=2048;break;         //AT89C2051x2
  91   2                      case 0x41: Allcodes=4096;break;         //AT89C4051
  92   2                      default: Allcodes=0;
  93   2              }
  94   1      }
  95          
  96          void SetMcuType()
  97          {
  98   1          if (Command=='T')
  99   1          {
 100   2                      Putchar('T');
 101   2                      Signature[1]=Getchar();
 102   2                      SetType();
 103   2                      Putchar('T');
 104   2          }   
 105   1      }
 106          
 107          void Write()
 108          {
 109   1          if (Command=='W')
 110   1          {
 111   2                      Putchar('W');
 112   2                      Sectors=Getchar();
 113   2                      Putchar('W');
 114   2                      Codes=Getchar();
 115   2                      Putchar('W');                           //Get The Total Number Of Codes Being To Write
 116   2                      Allcodes = Sectors * 256 + Codes;
 117   2                      DATA=0x1a;                                      //Avoid Status Reading
C51 COMPILER V7.10   X051                                                                  06/24/2005 03:20:11 PAGE 3   

 118   2                      OE=0;                                           //Enable Control Signal Output
 119   2                      ARST = 0;
 120   2                      ARST = 1;                                       //Address Reset
 121   2                      OE=1;
 122   2                      DATA=0x17;                                      //Ctr1=0,Ctr2=Ctr3=EVpp=1
 123   2                      EData=0;                                        //Lock the control signal
 124   2                      OE=0;                                           //Enable the control signal
 125   2                      for(i=0;i<Allcodes;i++)
 126   2                      {
 127   3                              DATA=Getchar();
 128   3                              Prog = 0;
 129   3                              Prog = 1;
 130   3                              Putchar('W');
 131   3                              while(!Busy);
 132   3                              Addr = 0;
 133   3                              Addr = 1;
 134   3                      }
 135   2                      OE=1;
 136   2                      EData=1;                                        //Enable Control Signal Transport
 137   2          }
 138   1      }
 139          
 140          void Read()
 141          {  
 142   1          if (Command=='R')
 143   1          {
 144   2                      DATA=0x1a;                                      //Avoid Status Reading
 145   2                      OE=0;                                           //Enable Control Signal Output
 146   2                      ARST = 0;
 147   2                      ARST = 1;                                       //Address Reset
 148   2                      OE=1;
 149   2                      DATA=0x12;                                      //Ctr1=Ctr2=0,Ctr3=1,EVpp=0
 150   2                      EData=0;                                        //Lock the control signal
 151   2                      DATA=0xff;
 152   2                      OE=0;                                           //Enable the control signal
 153   2                      for(i=0;i<Allcodes;i++)
 154   2                      {
 155   3                              Putchar(DATA);
 156   3                              Command=(char)(Getchar());
 157   3                              if(!(Command=='R')) i=Allcodes;
 158   3                              Addr = 0;
 159   3                              Addr = 1;
 160   3                      }
 161   2                      OE=1;
 162   2                      EData=1;                                        //Enable Control Signal Transport
 163   2          }
 164   1      }
 165          
 166          void ReadSignature()
 167          {
 168   1              if(Command=='S')
 169   1              {
 170   2                      DATA=0x1a;                                      //Avoid Status Reading
 171   2                      OE=0;                                           //Enable Control Signal Output
 172   2                      ARST=0;
 173   2                      ARST=1;                                         //Address Reset
 174   2                      OE=1;
 175   2                      DATA=0x10;                                      //Ctr1=Ctr2=Ctr3=EVpp=0
 176   2                      EData=0;                                        //Lock the control signal
 177   2                      DATA=0xff;
 178   2                      OE=0;                                           //Enable the control signal
 179   2                      Signature[0]=DATA;
C51 COMPILER V7.10   X051                                                                  06/24/2005 03:20:11 PAGE 4   

 180   2                      Putchar(Signature[0]);
 181   2                      Command=Getchar();
 182   2                      Addr=1;
 183   2                      Addr=0;
 184   2                      Signature[1]=DATA;
 185   2                      Putchar(Signature[1]);
 186   2                      Addr=1;
 187   2                      OE=1;
 188   2                      EData=1;                                        //Enable Control Signal Transport
 189   2                      SetType();
 190   2              }
 191   1      }
 192          
 193          void Erase()
 194          {
 195   1          if (Command=='E')
 196   1          {
 197   2                      DATA=0x19;                                      //Ctr1=1,Ctr2=Ctr3=0,EVpp=1
 198   2                      OE=0;                                           //Enable the control signal
 199   2                      Prog=0;
 200   2                      Delay1ms(10);
 201   2                      Prog=1;
 202   2                      OE=1;                                           //Eraze complete
 203   2      
 204   2                  /*Test blank to judge if Eraze is Successfully Oprated*/
 205   2                      
 206   2                      DATA=0x1a;                                      //Avoid Status Reading
 207   2                      OE=0;                                           //Enable Control Signal Output
 208   2                      ARST = 0;
 209   2                      ARST = 1;                                       //Address Reset
 210   2                      OE=1;
 211   2                      DATA=0x12;                                      //Ctr1=Ctr2=0,Ctr3=1,EVpp=0
 212   2                      EData=0;                                        //Lock the control signal
 213   2                      DATA=0xff;
 214   2                      OE=0;                                           //Enable the control signal
 215   2                      for(i=0;i<Allcodes;i++)
 216   2                      {
 217   3                              if (DATA==0xff)
 218   3                              {
 219   4                                      Addr = 0;
 220   4                                      Addr = 1;
 221   4                                      if (i==Allcodes-1) Putchar('E');
 222   4                              }
 223   3                              else
 224   3                              {
 225   4                                      Putchar('F');
 226   4                                      i=Allcodes;
 227   4                              }
 228   3                      }
 229   2                      OE=1;
 230   2                      EData=1;                                        //Enable Control Signal Transport
 231   2              }
 232   1      }
 233          
 234          void Lock()
 235          {
 236   1          if (Command=='L')
 237   1          {
 238   2                      DATA=0x1f;                                      //Ctr1=Ctr2=Ctr3=EVpp=1
 239   2                      OE=0;
 240   2                      Prog = 0;
 241   2                      Prog = 1;                                       //Program LockBit 1
C51 COMPILER V7.10   X051                                                                  06/24/2005 03:20:11 PAGE 5   

 242   2                      while(!Busy);
 243   2                      DATA=0x1d;                                      //Ctr1=Ctr2=1,Ctr3=0,EVpp=1
 244   2                      Prog = 0;
 245   2                      Prog = 1;                                       //Program LockBit 2
 246   2                      while(!Busy);
 247   2                      Putchar('L');
 248   2                      OE=1;
 249   2          }
 250   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    634    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =     13    ----
   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 + -