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

📄 main.lst

📁 CP2201和51单片机实现ARP ICMP IP UDP协议
💻 LST
字号:
C51 COMPILER V7.06   MAIN                                                                  12/04/2007 13:46:18 PAGE 1   


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

stmt level    source

   1          #include <string.h>
   2          #include <stdio.h>
   3          #include <stdlib.h>
   4          #include <absacc.h>
   5          #include <intrins.h>
   6          #include "cp2200.h"
   7          #include "arp.h"
   8          //#include "icmp.h"
   9          #include "udp.h"
  10          #include "eth.h"
  11          //#include "ip.h"
  12          #include "regdefine.h"
  13          #include "ne2000.h"
  14          #include "reg.h"
  15          #include "pubilc.h"
  16          /*************************************全局变量的声明**********************************/
  17          unsigned  xdata timer0_count; //定时器2中断使用 用于清狗
  18          union NetNode xdata myNode;//定义本机网络地址
  19          //extern union arp_table_type arp_tab[MaxLenARPtable];
  20          unsigned char xdata udp_test[10]={0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09}; 
  21          union ip_address_type xdata pc_ip_addr;
  22          /************************************初始化函数声明************************************/
  23          
  24          void cp2201_restart ();
  25          /*void init_watchdog();
  26          void start_on_watchdog();*/
  27          //void stop_watchdog();//看门狗
  28          //void pfarpb( );
  29          /*************************************主函数*******************************************/
  30          
  31          int main(void)
  32          {
  33   1              unsigned int tmp;
  34   1              INT8U xdata inbuf[342]; 
  35   1              SP=0x80; //设置椎栈起点
  36   1      //      IE=0x97;//开除了T1的所有中断
  37   1              EA=1;
  38   1              ET0=1; 
  39   1                  ET2=1;
  40   1              //      EX1=1;
  41   1              TMOD = 0x21;  /*time1,8bit auto-reload,mode 2*/
  42   1              TL1 = 0xf7;   
  43   1              TH1 = 0xf7;  /* crystal oscillator clock 33Mhz,PCON=1,and so baud-rate=19200 */
  44   1              SCON = 0x50;  /* SM0=0,SM1=1,SM2=0,select mode 1,REN=1 */
  45   1              PCON = 0x80;  /* double the baud rate */
  46   1              TR1 = 1; /* start timer1 */
  47   1              TL0 = 0x41;   
  48   1              TH0 = 0xf5;
  49   1              TR0 = 1; 
  50   1          
  51   1      //      init_watchdog();
  52   1      //      start_on_watchdog();
  53   1              TI=1;
  54   1             // printf ("\n test=%.2x \n",(unsigned int)test);
  55   1              printf ("PACBRIDGE");
C51 COMPILER V7.06   MAIN                                                                  12/04/2007 13:46:18 PAGE 2   

  56   1              cp2201_restart ();
  57   1               INT0EN = 0x03;                         
  58   1               INT1EN = 0x05;
  59   1               tmp=PHY_Init();
  60   1              printf ("\ntmp=%d\n" ,tmp);
  61   1              MAC_Init();
  62   1              arptab_init();
  63   1              myNode.node.ip = IP4_ADDR(192,168,1,218);
  64   1              myNode.node.mask = IP4_ADDR(255,255,255,0);
  65   1      //      myNode.node.gate = IP4_ADDR(192,168,1,1);
  66   1               pc_ip_addr.dwords=IP4_ADDR(192,168,1,104);
  67   1               RXCN = RXCLEAR;   //清除接受缓冲
  68   1      while(1)
  69   1              {
  70   2                      
  71   2                      if(CPRcv())         // Check if the current packet is valid
  72   2                      {                         // On detection of a valid packet:
  73   3                              num_bytes = CP220x_Receive(inbuf);
  74   3                              if(num_bytes > 0)
  75   3                              {    
  76   4                                 eth_rcve( inbuf);
  77   4                                updatearptab();
  78   4                              } 
  79   3                        }
  80   2            }
  81   1      }
  82                          
  83           
  84              
  85          
  86          /***********************************************中断函数************************************************/
  87          void Timer0_ISR (void) interrupt 1  //1ms
  88          {   
  89   1              TR0=0;
  90   1              TH0 = 0xF5;  
  91   1              TL0 = 0x41;
  92   1              if (Count1ms) Count1ms--;
  93   1              TR0=1;
  94   1              
  95   1      }
  96          void timer2_int(void) interrupt 6 using 0    
  97          {  
  98   1         TR2=0;
  99   1         TL2 = 0;
 100   1         TH2= 0;
 101   1         TF2=0;
 102   1        timer0_count++;
 103   1        if(timer0_count == 80)
 104   1         {
 105   2           timer0_count = 0;
 106   2           WDT = 1;   //refresh watchdog
 107   2          }
 108   1        TR2 = 1;
 109   1      }
 110          /******************************************初始化函数**********************************/
 111          /*void init_watchdog() //看门狗程序初始化
 112          {
 113                  WDTD = 0x00;    /*period=(255-WDTD)*344604*1/fosc*/
 114          //      WDTC = 0x18;  /*WDOUT=1,WDRE=1;*/
 115          //}
 116          /*void Timer0_Init (void)
 117          {
C51 COMPILER V7.06   MAIN                                                                  12/04/2007 13:46:18 PAGE 3   

 118                  TMOD|=0x1;      //16Bit
 119                  TH0 = 0xF5;             // set Timer0 to overflow in 1ms
 120                  TL0 = 0x41;
 121                  TR0 = 1;        // START Timer0 
 122           }*/
 123          /*void init_serial()   //串口初始化  定时器1为波特率发生器 19200  数据位8  奇偶校验无  停止位1
 124          {
 125            TMOD = 0x21;  /*time1,8bit auto-reload,mode 2
 126            TL1 = 0xf7;   
 127            TH1 = 0xf7;   // crystal oscillator clock 33Mhz,PCON=1,and so baud-rate=19200 
 128            SCON = 0x50;  //SM0=0,SM1=1,SM2=0,select mode 1,REN=1 
 129            PCON = 0x80;  //double the baud rate 
 130            TR1 = 1;      // start timer1 
 131            TI = 0;
 132          }*/
 133          /*void start_on_watchdog()
 134          {
 135           SWDT = 1; 
 136           TR2 = 1;   
 137          }
 138          void stop_watchdog()
 139          {
 140            SWDT = 0; 
 141            TR2 = 0;  
 142          }*/
 143          
 144          /*void pfarpb( )
 145           {
 146             INT8U i,j;
 147             printf ("\n");
 148              for(j=0;j<2;j++)
 149              {
 150              for(i=0;i<12;i++)
 151               {
 152               printf ("%.2x",(unsigned int)arp_tab[j].bytes[i]);
 153                printf ("-");       
 154                Delay1ms(10);
 155              }
 156               printf ("\n");
 157             }
 158           }*/
 159          void cp2201_restart ()
 160             {
 161   1         printf ("\CP2201 restart start  \n");
 162   1          RST=0;
 163   1              //加延时
 164   1              Delay1ms(50);
 165   1              Delay1ms(50);
 166   1         Delay1ms(500);
 167   1         RST=1;
 168   1              
 169   1         Delay1ms(200);
 170   1         Delay1ms(200);
 171   1        if(INT0RD&0x30)
 172   1        {
 173   2       // regint0_value=INT0RD;
 174   2        printf ("\CP2201 restart succeed   \n");}
 175   1        else 
 176   1        printf ("\CP2201 restart lost  \n");
 177   1       // printf ("\nINT0RD_RESTART=%.2x \n",(unsigned  int)regint0_value);
 178   1        
 179   1        }
C51 COMPILER V7.06   MAIN                                                                  12/04/2007 13:46:18 PAGE 4   



MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    312    ----
   CONSTANT SIZE    =     93    ----
   XDATA SIZE       =     36     342
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   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 + -