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

📄 main.lst

📁 this file is for keil keyboard
💻 LST
字号:
C51 COMPILER V7.06   MAIN                                                                  05/18/2006 14:10:09 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          #include "test.h"
   2          #define          GAIN_W_L8             XBYTE[0XB000]
   3          #define          GAIN_W_H4             XBYTE[0XB001]
   4          #define          GAIN_R_L8             XBYTE[0XB002]
   5          #define          GAIN_R_H4             XBYTE[0XB003]
   6          #define          GAIN_UPDATE           XBYTE[0XC000]
   7          #define          AD_START              XBYTE[0XA000]
   8          #define          AD_H8                 XBYTE[0XA000]
   9          #define          AD_L4                 XBYTE[0XA001]
  10          sbit      SCL=P1^3;    
  11          sbit      SDA=P1^4;              /*DEFINE   CLOCK LINE AND  DATA LINE  FIRST  */
  12          int    Sample0(  )
  13          {
  14   1                   unsigned   char xdata  IntNum    ;
  15   1                       unsigned   int  xdata  Cycle     ;
  16   1                       unsigned   int  xdata  DataW     ;
  17   1            
  18   1                       unsigned   int  xdata  DataWSum  ; 
  19   1      
  20   1                   
  21   1                       
  22   1                       DataWSum      =  0          ;
  23   1                       for ( Cycle = 0 ; Cycle < 30  ; Cycle++ )
  24   1                       {
  25   2                               IntNum     |= 0X80      ; 
  26   2                               AD_START    = 0x10      ;        //启动转换 
  27   2                               while( IntNum & 0X80 )           //工作通道转换结束,K开始接受数据
  28   2                               {
  29   3                                       IntNum =  ADDR_INT  ; 
  30   3                               }     
  31   2                               DataW      =  AD_H8     ;
  32   2                               DataW      =  _irol_ ( DataW , 4 );
  33   2                               DataW     +=  AD_L4  /16    ;
  34   2                               DataWSum  +=  DataW / 30 ;
  35   2                       }
  36   1                       return   DataWSum   ;
  37   1       
  38   1      }  
  39                    
  40           void  Start()
  41          {
  42   1        SDA=1;
  43   1        SCL=1;
  44   1        SDA=0;
  45   1        SCL=0;
  46   1      }                               /*开始的前导符*/                     
  47          void  Stop()
  48          {
  49   1       
  50   1        
  51   1        SDA=0;
  52   1        SCL=1;
  53   1        SDA=1;
  54   1        SCL=0;
  55   1        SDA=0;
C51 COMPILER V7.06   MAIN                                                                  05/18/2006 14:10:09 PAGE 2   

  56   1        
  57   1       
  58   1      }
  59          void Send(unsigned  char    SendData)   
  60          {
  61   1          unsigned    char       temp;
  62   1          unsigned    char       i;
  63   1         SCL=0;
  64   1         for (i=0;i<8;i++)
  65   1         {
  66   2          temp=SendData ;
  67   2          temp=temp&0x80; 
  68   2               
  69   2          if (temp==0x80)              /*bit 7 is  1*/
  70   2          {
  71   3              SDA=1;
  72   3          }
  73   2          else
  74   2          {
  75   3              SDA=0; 
  76   3          }
  77   2         
  78   2              SCL=1;
  79   2              SCL=0;
  80   2                       
  81   2              SendData=SendData<<1;
  82   2         } /*  end  for  i*/
  83   1         
  84   1         SDA=1;
  85   1            
  86   1         SCL=1;
  87   1         while(SDA) {}                    /*JUDGE WHETHER ACKNOWLEDGE IS OCCUR OR  NOT*/  
  88   1         SCL=0; 
  89   1         
  90   1      }                                                  /*发送数据*/
  91           void   Start_2464(unsigned  char       rw,        /*读或写的标志*/
  92                                 unsigned  char       ChipID )    /*24c256的硬件的编址*/
  93                                                                             
  94                                   
  95           {     
  96   1                 unsigned   char            byte;
  97   1                 rw&=0x01;
  98   1                 byte=0xa0;
  99   1                 byte|=rw;
 100   1                 ChipID&=0x07;                               /*get  low  three  bit  */
 101   1                 ChipID=ChipID<<1;
 102   1                 byte|=ChipID; 
 103   1                 Start();
 104   1                   
 105   1                 Send(byte);
 106   1                  
 107   1                 
 108   1       }
 109           void   ByteWrite_2464(    unsigned  char     ChipID  ,
 110                                     unsigned  int      addr    ,     /*待发送的数的首址*/
 111                                         unsigned  char     senddata)     /*   待发送的数   */
 112           {                                        
 113   1               unsigned  char       temp;
 114   1               
 115   1           Start_2464(0x00,ChipID);
 116   1           temp= addr>>8 ;                                   /*high  address  */
 117   1               Send(temp);
C51 COMPILER V7.06   MAIN                                                                  05/18/2006 14:10:09 PAGE 3   

 118   1               temp=addr&0x00ff;                                 /*low   address  */
 119   1               Send(temp);
 120   1           Send(senddata);
 121   1               Stop();
 122   1               for (temp=0;temp<0xff ;temp++);           /*对于I2C总线而言延时是最重要的,*/
 123   1               for (temp=0;temp<0xff;temp++);
 124   1           for (temp=0;temp<0xff ;temp++);           /*对于I2C总线而言延时是最重要的,*/
 125   1               for (temp=0;temp<0xa0;temp++);
 126   1             
 127   1            
 128   1                 
 129   1       }
 130           char   Get_2464   ()                  /*获取一个字节的数据*/
 131           {
 132   1               unsigned   char        getdata;
 133   1               unsigned   char        cycle  ;
 134   1               getdata=0x00;
 135   1              
 136   1               for (cycle=0;cycle<8;cycle++)      /*一共要接受8个字节的数据*/ 
 137   1               {
 138   2                       getdata=getdata<<1;
 139   2                       SCL=1;
 140   2                       if (SDA)                       /*SDA=1*/
 141   2                       {
 142   3                 getdata|=0x01;  
 143   3                       }
 144   2                       else                           /*SDA=0*/
 145   2                       {
 146   3                 getdata|=0x00;
 147   3                       }
 148   2                       SCL=0;
 149   2                         
 150   2               }                                /*end  for  cycle*/    
 151   1               return   getdata;
 152   1      
 153   1                
 154   1       }                                  
 155           
 156           void   SequentialRead_2464( unsigned  char     ChipID ,
 157                                       unsigned  char     *Buffer, /*存放数据的首址,读取的数据全部存储到外部的数据存
             -储器*/
 158                                       unsigned  int      num    )    /*读取数据的字节数*/  
 159           {
 160   1           unsigned  int          cycle;  
 161   1           unsigned  char         senddata;
 162   1         
 163   1           
 164   1            
 165   1           Start_2464(0X01,ChipID);
 166   1           for (cycle=0;cycle<num;cycle++)
 167   1               {
 168   2                senddata=Get_2464();
 169   2                Buffer[cycle]=senddata;                            /*送到外部的数据存储器*/
 170   2                        
 171   2                        if(cycle==num-1)                             /*the  last byte  data need not  ACK*/ 
 172   2                        {                                            
 173   3                               SDA=1;
 174   3                               SCL=1;
 175   3                               SCL=0;                    /*NOACK*/
 176   3                               Stop();
 177   3                               break;
 178   3                        }                            
C51 COMPILER V7.06   MAIN                                                                  05/18/2006 14:10:09 PAGE 4   

 179   2                        SDA=0;                       /*ACK*/
 180   2                        SCL=1;                       /*ACK*/   
 181   2                        SCL=0;                       /*ACK*/
 182   2                        SDA=1;                       /*ACK*/
 183   2               }                                                  /*end for  cycle*/
 184   1       }
 185           void   RandomRead_2464(unsigned  char          ChipID ,
 186                                  unsigned  char          *Buffer,/*读取的数据放到外部的数据存储器waddr就是外部的数

⌨️ 快捷键说明

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