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

📄 main.lst

📁 单片机控制RTL8019AS的程序,C语言编写,仿真通过.
💻 LST
字号:
C51 COMPILER V7.06   MAIN                                                                  10/09/2006 21:51:56 PAGE 1   


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

stmt level    source

   1          //---------------------------------------------------------------------------
   2          // Net MAIN.C
   3          //
   4          // 8051 Web Server project
   5          // See Makefile for build notes 
   6          // Written for Keil C51 V5.1 compiler, notes:
   7          //   It uses big endian order, which is the same as the
   8          //   network byte order, unlike x86 systems.
   9          //   Use OPTIMIZE(2)or higher so that automatic variables get shared
  10          //   between functions, to stay within the 256 bytes idata space
  11          //---------------------------------------------------------------------------
  12          
  13          #include <string.h>
  14          #include <stdlib.h>
  15          #include <general.h>
  16          
  17          
  18          // Global variables
  19          UINT volatile event_word;
  20          char xdata text[20];  
  21          UCHAR idata rcve_buf_allocated;
  22          
  23          
  24          // This sets my hardware address
  25          UCHAR code my_hwaddr[6] = {0x00,0x11,0xD8,0xD7,0x99,0xF9}; 
  26          
  27          // Hardware addr to send a broadcast
  28          UCHAR code broadcast_hwaddr[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
  29          
  30          // This sets my IP address to 202.114.57.107
  31          ULONG code  my_ipaddr = 0xCA72396BL;
  32          
  33          // This sets my subnet mask to 255.255.255.0
  34          ULONG code my_subnet = 0xFFFFFF00L;
  35          
  36          // This sets gateway ip address to 202.114.57.1
  37          ULONG code gateway_ipaddr = 0xCA723901L;
  38          
  39          //--------------------------------------------------------------------------
  40          // Initialize the memory management routines
  41          // Initialize variables declared in main
  42          //--------------------------------------------------------------------------
  43          
  44          unsigned int Count1msInc;
  45          unsigned char Count1ms,Count10ms,Count1s;
  46          unsigned char TimeSecond,TimeMinute;
  47          sbit P10=P1^0;
  48          sbit ET2   = IE^5;
  49          void init_main(void)
  50          {
  51   1              // Start the memory pool for incoming and outgoing Ethernet
  52   1              // frames at 1000, with length = 1500 bytes. Memory below 500
  53   1              // is used for program variables
  54   1              init_mempool((void xdata *)1000, 1500);
  55   1              memset(text, 0, sizeof(text));
C51 COMPILER V7.06   MAIN                                                                  10/09/2006 21:51:56 PAGE 2   

  56   1              event_word = 0;
  57   1              rcve_buf_allocated = FALSE;
  58   1      }
  59          
  60          
  61          
  62          void Timer0_Init (void)
  63          {
  64   1              TMOD|=0x1;      //16Bit
  65   1              Count10ms=10;
  66   1              Count1s=0;
  67   1              TR0 = 0;                                // STOP Timer0
  68   1              TH0 =0xF5;      // set Timer0 to overflow in 1ms
  69   1              TL0 =0x96;
  70   1              TR0 = 1;        // START Timer0
  71   1              IE|= 0x2; 
  72   1      }
  73          
  74          void Timer0_ISR (void) interrupt 1  //1ms
  75          {
  76   1              TH0 = 0xF5;
  77   1              TL0 =0x96;
  78   1              if (Count1ms) Count1ms--;
  79   1              Count1msInc++;
  80   1              if (Count10ms) Count10ms--;
  81   1              else
  82   1              {
  83   2                      Count10ms=10;                           //10ms
  84   2                      if (Count1s) Count1s--;
  85   2                      else
  86   2                      {
  87   3                              Count1s=100;                    //1s
  88   3                              TimeSecond++;
  89   3                              if (TimeSecond>=60)
  90   3                              {
  91   4                                      TimeSecond=0;           //1min
  92   4                                      TimeMinute++;
  93   4                                      if      (TimeMinute==60)        TimeMinute=0;
  94   4                              }
  95   3                      }
  96   2              }
  97   1      }
  98          
  99          
 100          void Delay1ms(unsigned char T)
 101          {
 102   1              Count1ms=T;
 103   1              while (Count1ms);
 104   1      }
 105          
 106          
 107          
 108          void LightONOFF(bit b)
 109          {
 110   1      
 111   1              if (b)
 112   1              {
 113   2                      P10=0;
 114   2              }
 115   1              else
 116   1              {
 117   2                      P10=1;
C51 COMPILER V7.06   MAIN                                                                  10/09/2006 21:51:56 PAGE 3   

 118   2              }
 119   1      }
 120          
 121          
 122          void main (void)
 123          {
 124   1              UINT j, event_word_copy;
 125   1              UCHAR xdata * inbuf;
 126   1                              
 127   1              Timer0_Init();
 128   1      
 129   1              init_main();
 130   1              init_tcp();
 131   1              init_http();
 132   1      
 133   1              EA=1;
 134   1              init_timer2();
 135   1              init_arp();
 136   1              init_8019();
 137   1         
 138   1              
 139   1      
 140   1              j = 0;
 141   1              ET2 = 1;                            // Enable timer 2 interrupt
 142   1                      
 143   1      
 144   1              while (1)
 145   1         {
 146   2            query_8019();
 147   2            
 148   2            // Use a copy of event word to avoid interference
 149   2            // with interrupts
 150   2                      EA = 0;
 151   2                      event_word_copy = event_word;
 152   2                      EA = 1;
 153   2            
 154   2            // See if an Ethernet frame has arrived      
 155   2            if (event_word_copy & EVENT_ETH_ARRIVED)
 156   2            {
 157   3               EA = 0;
 158   3               event_word &= (~EVENT_ETH_ARRIVED);
 159   3               EA = 1;
 160   3               
 161   3               // Allocate a buffer and read frame from CS8900A
 162   3               inbuf = rcve_frame();
 163   3               if (inbuf != NULL)
 164   3               {
 165   4                  // Process the received Ethernet frame 
 166   4                  eth_rcve(inbuf); 
 167   4               
 168   4                  // If the memory allocated for the rcve message has
 169   4                  // not already been freed then free it now
 170   4                  if (rcve_buf_allocated)
 171   4                  {
 172   5                     free(inbuf);
 173   5                     rcve_buf_allocated = FALSE;
 174   5                  }
 175   4               }
 176   3            }
 177   2            
 178   2            // See if TCP retransmit timer has expired                       
 179   2            else if (event_word_copy & EVENT_TCP_RETRANSMIT)
C51 COMPILER V7.06   MAIN                                                                  10/09/2006 21:51:56 PAGE 4   

 180   2            {
 181   3               EA = 0;
 182   3               event_word &= (~EVENT_TCP_RETRANSMIT);
 183   3               EA = 1;
 184   3               tcp_retransmit();
 185   3                      }
 186   2      
 187   2            // See if TCP inactivity timer has expired
 188   2            else if (event_word_copy & EVENT_TCP_INACTIVITY)
 189   2            {
 190   3               EA = 0;
 191   3               event_word &= (~EVENT_TCP_INACTIVITY);
 192   3               EA = 1;
 193   3               tcp_inactivity();
 194   3                      }
 195   2      
 196   2            // See if ARP retransmit timer has expired
 197   2                      else if (event_word_copy & EVENT_ARP_RETRANSMIT)
 198   2            {
 199   3               EA = 0;
 200   3               event_word &= (~EVENT_ARP_RETRANSMIT);
 201   3               EA = 1;
 202   3               arp_retransmit();
 203   3                      }
 204   2      
 205   2            // See if it is time to age the ARP cache
 206   2            else if (event_word_copy & EVENT_AGE_ARP_CACHE)
 207   2            {
 208   3               EA = 0;
 209   3               event_word &= (~EVENT_AGE_ARP_CACHE);
 210   3                              EA = 1;
 211   3               age_arp_cache();
 212   3                      }
 213   2         }
 214   1      }
 215          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    304    ----
   CONSTANT SIZE    =     24    ----
   XDATA SIZE       =     20    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      9       6
   IDATA SIZE       =      1    ----
   BIT SIZE         =   ----       1
END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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