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

📄 main.lst

📁 这是单片机仿真模数转换的一个源码实验
💻 LST
字号:
C51 COMPILER V7.50   MAIN                                                                  08/20/2008 12:20:17 PAGE 1   


C51 COMPILER V7.50, 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

line level    source

   1          #include <reg51.h>
   2          #include <intrins.h>
   3          #define uint unsigned int 
   4          #define uchar unsigned char
   5          
   6          sbit DIN  = P2^0;
   7          sbit LOAD = P2^1;
   8          sbit CLK  = P2^2;
   9          
  10          sbit dout=P1^4; 
  11          sbit sclk=P1^5; 
  12          sbit cs = P1^6;
  13          sbit shdn=P1^7; 
  14          /*sbit DOUT=P1^4;       
  15          sbit SCLK=P1^5; 
  16          sbit CS = P1^6;
  17          sbit SHDN=P1^7;*/
  18          
  19          sbit LED  = P1^0;
  20          
  21          void Write7129( uchar Add, uchar Data );
  22          void Init7219( void );          // initialize 7219      
  23          void DelayMs( uchar n );
  24          uint Rec_data;
  25          void max1240(void);
  26          uchar DispBuf[8]={1,2,3,4,5,6,7,8};             // display buffer
  27          
  28          /*
  29          void max1240(void)
  30          {
  31            uchar i; 
  32            float temp;
  33            uint rice;
  34            //CS = 1; 
  35             
  36            
  37             //DOUT = 1;
  38            // _nop_(); _nop_();  _nop_(); _nop_();
  39             CS = 0;
  40             SCLK = 0;
  41                  _nop_();
  42             //DOUT = 0; _nop_();
  43           if(DOUT==0)
  44            {
  45               _nop_();_nop_(); _nop_(); _nop_(); _nop_(); _nop_();_nop_();
  46            if(DOUT==1)
  47             {
  48               for(i=0;i<12;i++)
  49               {
  50                      SCLK = 1; _nop_();
  51                  SCLK = 0;
  52                     // Rec_data <<=1;     
  53                           if(DOUT==1)
  54                             Rec_data = (Rec_data<<=1) | 0x0001;   
  55                       else Rec_data <<=1; 
C51 COMPILER V7.50   MAIN                                                                  08/20/2008 12:20:17 PAGE 2   

  56                   }
  57                  CS = 1;
  58             }
  59            }
  60          
  61          temp = (float)Rec_data*0.6105006;
  62            //Pdata = (int)temp;
  63          rice=(uint)temp;
  64          
  65          DispBuf[0]=(rice%10000)/1000;
  66          
  67          DispBuf[1]=(rice%1000)/100;
  68          
  69          DispBuf[2]=(rice%100)/10;
  70          
  71          DispBuf[3]=rice%10;
  72          }*/
  73          void adcover(void)
  74          { uint rice=0;
  75   1        uchar i;
  76   1      float rice1=0;
  77   1       sclk=0;
  78   1       cs=0;
  79   1      _nop_();
  80   1      if(dout==0)
  81   1      {_nop_();
  82   2      _nop_();
  83   2      _nop_();
  84   2      _nop_();
  85   2      _nop_();
  86   2      _nop_();
  87   2      _nop_();
  88   2      
  89   2      if(dout==1)
  90   2      { 
  91   3        for(i=0;i<12;i++)
  92   3        { sclk=1;
  93   4        _nop_();
  94   4        sclk=0;
  95   4        
  96   4       if(dout==1)
  97   4         {rice=(rice<<1)|0x0001;}
  98   4       else   
  99   4       rice=rice<<1;
 100   4         }
 101   3         cs=1;} 
 102   2      }
 103   1      
 104   1      rice1=(float)rice*0.6105006;//(2.5*rice*1000)/0xfff;
 105   1      
 106   1      
 107   1      rice=(uint)rice1;
 108   1      
 109   1      DispBuf[0]=(rice%10000)/1000;
 110   1      
 111   1      DispBuf[1]=(rice%1000)/100;
 112   1      
 113   1      DispBuf[2]=(rice%100)/10;
 114   1      
 115   1      DispBuf[3]=rice%10;
 116   1      
 117   1      }
C51 COMPILER V7.50   MAIN                                                                  08/20/2008 12:20:17 PAGE 3   

 118          
 119          /*void Process()
 120          {
 121            float temp;
 122            uint rice;
 123            max1240();
 124           // temp =  (Rec_data*2.5)/0xfff;
 125            //temp = temp*1000;
 126            temp = (float)Rec_data*0.6105006;
 127            //Pdata = (int)temp;
 128          rice=(uint)temp;
 129          
 130          DispBuf[0]=(rice%10000)/1000;
 131          
 132          DispBuf[1]=(rice%1000)/100;
 133          
 134          DispBuf[2]=(rice%100)/10;
 135          
 136          DispBuf[3]=rice%10;
 137          }*/
 138          
 139          void main()
 140          {
 141   1              DelayMs( 1000 );
 142   1              Init7219( );
 143   1              Write7129( 0x01 , DispBuf[0] );
 144   1              Write7129( 0x02 , DispBuf[1] );
 145   1              Write7129( 0x03 , DispBuf[2] );
 146   1              Write7129( 0x04 , DispBuf[3] );
 147   1              Write7129( 0x05 , DispBuf[4] );
 148   1              Write7129( 0x06 , DispBuf[5] );
 149   1              Write7129( 0x07 , DispBuf[6] );
 150   1              Write7129( 0x08 , DispBuf[7] );
 151   1                      
 152   1              LED  = 0 ;
 153   1              while(1)
 154   1              {
 155   2         // max1240();
 156   2          adcover();
 157   2          Write7129( 0x01 , DispBuf[0] );
 158   2              Write7129( 0x02 , DispBuf[1] );
 159   2              Write7129( 0x03 , DispBuf[2] );
 160   2              Write7129( 0x04 , DispBuf[3] );
 161   2              Write7129( 0x05 , DispBuf[4] );
 162   2              Write7129( 0x06 , DispBuf[5] );
 163   2              Write7129( 0x07 , DispBuf[6] );
 164   2              Write7129( 0x08 , DispBuf[7] );
 165   2      
 166   2              }
 167   1      
 168   1      }
 169          void Init7219( void )
 170          {
 171   1              Write7129( 0x0c , 0x01);                //开启
 172   1              Write7129( 0x09 , 0xff );               //译码方式 B译码
 173   1              Write7129( 0x0a , 0x04 );               //亮度
 174   1              Write7129( 0x0b , 0x03 );               //扫描界限      
 175   1      }
 176          
 177          void Write7129( uchar Add, uchar Data )
 178          {
 179   1              uint Send;
C51 COMPILER V7.50   MAIN                                                                  08/20/2008 12:20:17 PAGE 4   

 180   1              uchar i;
 181   1              Send = Add*0x100 + Data;
 182   1            LOAD = 1;
 183   1            _nop_();
 184   1            _nop_();
 185   1                LOAD = 0;
 186   1                _nop_();
 187   1                _nop_();
 188   1          for(i=0;i<16;i++)
 189   1           {
 190   2             CLK = 0;
 191   2              _nop_();
 192   2             DIN = 0;
 193   2                if((Send & 0x8000) == 0x8000)
 194   2                   DIN = 1;
 195   2               _nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();
 196   2             CLK = 1;
 197   2             _nop_();
 198   2             _nop_();
 199   2             Send <<= 1;
 200   2           }
 201   1               LOAD = 1;
 202   1                _nop_();
 203   1           CLK = 0;
 204   1               _nop_();
 205   1               _nop_();
 206   1               _nop_();
 207   1               _nop_();
 208   1      //       LOAD = 0;
 209   1               // wirte your code here
 210   1      }
 211          
 212          void DelayMs( uchar n )
 213          {
 214   1              uchar i;
 215   1              while( n-- )
 216   1              {
 217   2                      for( i = 0 ; i < 125 ; i++ )
 218   2                              ;
 219   2              }
 220   1      }


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