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

📄 main.lst

📁 用at89c2051做avr910串口下载器的资料。很好的。对没有并口的朋友来说是一大福音。
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V8.08   MAIN                                                                  12/09/2007 20:15:04 PAGE 1   


C51 COMPILER V8.08, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN .\Main.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE ..\avrisp2051\制作资料\Main.c BROWSE DEBUG OBJECTEXTEND PRINT(.\Main.lst) O
                    -BJECT(.\Main.obj)

line level    source

   1          #include <REG2051.H>
   2          #include <intrins.H>
   3          
   4          //#define SL_BOARD  /*双龙ISP板*/
   5          //#define SOME_CHIP /*只支持少数几种芯片*/
   6          
   7                  sbit LED_RED1  = P3^3;
   8                  sbit LED_RED2  = P3^4;
   9                  sbit LED_GREEN = P3^5;
  10          
  11                  sbit MOSI  = P1^6;
  12                  sbit MISO  = P1^5;
  13                  sbit SCK   = P1^7;
  14                  sbit RESET = P1^4;
  15          
  16          
  17          #ifdef SOME_CHIP  /*  只支持生产所用的芯片,避免太多的芯片选择导至出错!!!  */
                      code DeviceType[][2]=
                      {
                      //AT90S8515
                              0x38,0,
                      //ATmega8515
                              0x3A,'P',
                      //ATmega8515 BOOT
                              0x3B,'P',
                      //ATmega8
                              0x76,'P',
                      //ATmega8 BOOT
                              0x77,'P',
                      };
              #else   
  32                  code DeviceType[][2]=
  33                  {
  34                  //AT90S1200 rev. A
  35                          0x10,0,
  36                  //AT90S1200 rev. B      
  37                          0x11,0,
  38                  //AT90S1200 rev. C
  39                          0x12,0,
  40                  //AT90S1200
  41                          0x13,0,
  42                  //AT90S2313
  43                          0x20,0,
  44                  //AT90S4414
  45                          0x28,0,
  46                  //AT90S4433
  47                          0x30,0,
  48                  //AT90S2333
  49                          0x34,0,
  50                  //AT90S8515
  51                          0x38,0,
  52                  //ATmega8515
  53                          0x3A,'P',
  54                  //ATmega8515 BOOT
C51 COMPILER V8.08   MAIN                                                                  12/09/2007 20:15:04 PAGE 2   

  55                          0x3B,'P',
  56                  //ATmega103
  57                          0x41,'P',
  58                  //ATmega603
  59                          0x42,'P',
  60                  //ATmega128
  61                          0x43,'P',
  62                  //ATmega128 BOOT
  63                          0x44,'P',
  64                  //AT90S2323
  65                          0x48,0,
  66                  //AT90S2343
  67                          0x4C,0,
  68                  //ATtiny11
  69                          0x50,0,
  70                  //ATtiny10
  71                          0x51,0,
  72                  //ATtiny12
  73                          0x55,0,
  74                  //ATtiny15
  75                          0x56,0,
  76                  //ATtiny19
  77                          0x58,0,
  78                  //ATtiny28
  79                          0x5C,0,
  80                  //ATtiny26
  81                          0x5E,'P',
  82                  //ATmega161
  83                          0x60,'P',
  84                  //ATmega161 BOOT
  85                          0x61,'P',
  86                  //ATmega163
  87                          0x64,'P',
  88                  //ATmega83
  89                          0x65,'P',
  90                  //ATmega163 BOOT
  91                          0x66,'P',
  92                  //ATmega83 BOOT
  93                          0x67,'P',
  94                  //AT90S8535
  95                          0x68,0,
  96                  //ATmega8535??
  97                          0x6A,'P',
  98                  //ATmega8535 BOOT??
  99                          0x6B,'P',
 100                  //AT90S4434
 101                          0x6C,0,
 102                  //AT90C8534
 103                          0x70,0,
 104                  //AT90C8544
 105                          0x71,0,
 106                  //ATmega32
 107                          0x72,'P',
 108                  //ATmega32 BOOT
 109                          0x73,'P',
 110                  //ATmega16
 111                          0x74,'P',
 112                  //ATmega16 BOOT
 113                          0x75,'P',
 114                  //ATmega8
 115                          0x76,'P',
 116                  //ATmega8 BOOT
C51 COMPILER V8.08   MAIN                                                                  12/09/2007 20:15:04 PAGE 3   

 117                          0x77,'P',
 118                  //AT89C1051
 119                  //      0x80,0
 120                  //AT89C2051
 121                  //      0x81,0
 122                  //AT89S8252
 123                          0x86,0,
 124                  //AT89S53
 125                          0x87,0
 126                  };
 127          #endif
 128          
 129          #define SW_MAJOR '3'            /*Major SW revision number*/
 130          #define SW_MINOR '0'            /*Minor SW revision number*/
 131          #define HW_MAJOR '1'            /*Major HW revision number*/
 132          #define HW_MINOR '0'            /*Minor HW revision number*/
 133          
 134          unsigned char loop,device,pgm_mode;
 135          unsigned char Addr_H,Addr_L ;
 136          unsigned char command;
 137          
 138          
 139          void Delay(unsigned int time)
 140          {
 141   1              while(time) time--;
 142   1      }
 143          
 144          void pulse_sck(void)
 145          {
 146   1              SCK = 1;
 147   1              _nop_();
 148   1              _nop_();
 149   1              _nop_();
 150   1              SCK = 0;
 151   1      }
 152          
 153          void IncAddrAuto()
 154          {
 155   1              Addr_L++;
 156   1      
 157   1              if(Addr_L == 0 )
 158   1                      Addr_H++;
 159   1      }
 160          
 161          void init_serial(void)
 162          {
 163   1           SCON = 0X50;/*Timer 1 is being used to generate baud rates.*/
 164   1           PCON = 0X80 | PCON;
 165   1           TMOD = 0X20;
 166   1           TH1 = 0XFD;
 167   1           TR1 = 1;            /*TCON.6*/
 168   1      //   ES = 1;            /*IE.4      */
 169   1           RI = 0;              /*SCON.0*/
 170   1      }
 171          
 172          unsigned char getc()
 173          {
 174   1              unsigned char buff;
 175   1      
 176   1              while(RI == 0);
 177   1              buff = SBUF;
 178   1              RI = 0;
C51 COMPILER V8.08   MAIN                                                                  12/09/2007 20:15:04 PAGE 4   

 179   1              return buff;
 180   1      }
 181          
 182          void putc(unsigned char ch)
 183          {
 184   1              SBUF = ch ;
 185   1              _nop_();
 186   1              _nop_();
 187   1              while( TI==0 );
 188   1              TI =0;
 189   1      }
 190          
 191          void showID()
 192          {
 193   1              code char ID[]={"AVR ISP"};
 194   1      
 195   1              for(loop=0;loop<sizeof(ID)-1;loop++) //ID-1是不要发串末的0
 196   1                      putc ( ID[loop] );
 197   1      }
 198          
 199          void show_device(void)
 200          {
 201   1              for(    loop=0;
 202   1                              loop< sizeof(DeviceType)/sizeof(DeviceType[0]);
 203   1                              loop++          )
 204   1                      putc ( DeviceType[loop][0] );
 205   1      }
 206          
 207          unsigned char check_device(unsigned char device)
 208          {
 209   1              for(    loop=0;
 210   1                              loop< sizeof(DeviceType)/sizeof(DeviceType[0]);
 211   1                              loop++          )
 212   1              {
 213   2                      if(device == DeviceType[loop][0] )
 214   2                              return DeviceType[loop][1];
 215   2              }
 216   1              return '?';
 217   1      }
 218          
 219          unsigned char wrser(unsigned char dat)
 220          {
 221   1              unsigned char indat = 0;
 222   1              for(loop = 0;loop<8;loop++)
 223   1              {
 224   2                      if( dat & 0x80 )
 225   2                              MOSI = 1;
 226   2                      else
 227   2                              MOSI = 0;
 228   2      
 229   2                      dat <<=1;
 230   2      
 231   2                      indat <<= 1;
 232   2      
 233   2                      if(MISO)
 234   2                              indat |= 1;
 235   2      
 236   2                      pulse_sck();
 237   2              }
 238   1      
 239   1              return indat;
 240   1      }
C51 COMPILER V8.08   MAIN                                                                  12/09/2007 20:15:04 PAGE 5   

 241          
 242          void spiinit()
 243          {
 244   1              unsigned char count;
 245   1      
 246   1              SCK = 0;
 247   1              RESET = 1;
 248   1              Delay(10);
 249   1              RESET = 0;
 250   1              Delay(10);
 251   1      
 252   1              wrser(0xac);            // SPI write (byte 1)

⌨️ 快捷键说明

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