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

📄 suidao1.lst

📁 隧道灯控制 隧道灯控制 隧道灯控制
💻 LST
📖 第 1 页 / 共 3 页
字号:
C51 COMPILER V7.50   SUIDAO1                                                               09/26/2007 09:17:54 PAGE 1   


C51 COMPILER V7.50, COMPILATION OF MODULE SUIDAO1
OBJECT MODULE PLACED IN E:\SUIDAO~3\SUIDAO1.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE E:\SUIDAO~3\SUIDAO1.C DB SB OE

line level    source

   1           #include <reg51.h>
   2          
   3           #define uchar unsigned char
   4           #define uint  unsigned int
   5          
   6           #define start_byte 0xca
   7           #define end_byte 0xcc
   8           #define DimmChangeTime 30
   9           #define LEDAFACE  11
  10           #define WithOutComConst 30
  11          /*
  12          P03             P02             P01             P00
  13          A绿     A红             B绿             B红
  14          LED1    LED2    LED3    LED4
  15          */
  16          // #define ADDRESS 0x31
  17          
  18          //FUN: from 0x30 to 0x38
  19          //CHK: = (0xca+add+FUN+DATA0+DATA1+0xcc)%0xff
  20            //======= Var Define =======
  21           uchar data us100_cnt,ms_cnt,ms100_cnt; //system timer
  22           uchar data scount;
  23           uchar data address;
  24           uint data bright;
  25           uint data I1,I2;
  26           uint data TI1,TI2;
  27           uchar data cnt11,cnt22,cnt33,cnt44;
  28          
  29          
  30          uchar data countad=0;
  31           uchar idata rbuf[14];
  32           uchar idata tbuf[14];
  33           uchar data comm_gap,i,j,tran_len,rececnt;
  34           uchar idata *rece_p;
  35           uchar idata *tran_p;
  36           uchar  data ad_buf[8];
  37          // uchar  idata  Status[4];
  38           uchar data adchannel,BeepCnt,Dimm1,Dimm2,Dimm1Cnt,Dimm2Cnt;
  39           uchar data dimmcnt1,dimmcnt2,Dimm1Changed,Dimm2Changed;
  40           uchar data instate;
  41          //bit Status=1;
  42           uchar bdata OutStatus;
  43          
  44          sbit Led1 = OutStatus^3;
  45          sbit Led2 = OutStatus^2;
  46          sbit Led3 = OutStatus^1;
  47          sbit Led4 = OutStatus^0;
  48          //uchar bdata Outerr;
  49          //sbit outstate1R = Outerr^0;
  50          //sbit outstate1G = Outerr^1;
  51          //sbit outstate2R = Outerr^2;
  52          //sbit outstate2G = Outerr^3;
  53          bit outstate1R ;
  54          bit outstate1G  ;
  55          bit outstate2R ;
C51 COMPILER V7.50   SUIDAO1                                                               09/26/2007 09:17:54 PAGE 2   

  56          bit outstate2G ;
  57          
  58          
  59             //======= Bit Define =======
  60           bit rfin,rsta,t10ms,t100ms,dimmauto,conv1,conv2,tsta,adready,G_LED1,G_LED2;
  61          
  62           //uint code DimmerYZ[2] = {18,120};
  63           //uchar code DimTab[3] = {50,25,15};
  64                                     //   1     2     3     4
  65           uchar code LIMIT[3][4][3] ={{{3,50,105},{3,50,135},{3,50,105},{3,50,135}},  //high dimmer
  66                                       {{3,40,55},{3,52,70},{3,40,55},{3,52,70}},  //mid dimmer
  67                                       {{3,23,35},{3,32,45},{3,23,35},{3,32,45}}}; //low dimmer
  68          
  69          // uchar code BITMASK[8] = {1,2,4,8,0x10,0x20,0x40,0x80};
  70           uchar code ADMASK[8] = {0,0x80,0x40,0xc0,0x20,0xa0,0x60,0xe0};
  71          
  72            //======= I/O Define ========
  73          //sbit CS_5045=P3^5;
  74          //sbit STB_LED=P1^6;
  75          
  76          //sbit ERRLED = P3^7;
  77          //sbit TRE485 = P3^3;
  78          
  79          sbit SWLED1 = P2^0;
  80          sbit SWLED2 = P2^1;
  81          sbit SWLED3 = P2^2;
  82          
  83          sbit CON_AD1=P0^6;
  84          sbit CON_AD2=P2^6;
  85          
  86          //sbit ConvertSta = P2^0;
  87          //sbit ADIN = P3^2;
  88          sbit LED1R = P0^0;
  89          sbit LED1G = P0^1;
  90          sbit LED2R = P0^2;
  91          sbit LED2G = P0^3;
  92          sbit state2G = P3^4;
  93          sbit state2R = P3^5;
  94          sbit state1G = P3^6;
  95          sbit state1R = P3^7;
  96          
  97          bit flag1 = 1;
  98          //bit flag2 = 1;
  99          uchar data count1 = 0;
 100          //uchar data count2 = 0;
 101          uchar data i;
 102          
 103          //======= Function Define ========
 104          // void ClrLed(void);
 105           //void delay(uint a);
 106           extern uchar read_ad();
 107           //========= Main Programm =========
 108           MAIN ()
 109          {
 110   1      //uchar data ii;
 111   1          //TRE485 = 0;
 112   1      
 113   1          OutStatus = 0xff;
 114   1          TMOD=0x12;
 115   1          TH0=256-100;
 116   1          TL0=256-100;
 117   1      
C51 COMPILER V7.50   SUIDAO1                                                               09/26/2007 09:17:54 PAGE 3   

 118   1      //    PCON |= 0x80;
 119   1      //    SCON = 0x50;
 120   1      
 121   1      //    RCAP2H=0xff;
 122   1      //    RCAP2L=0xdc;  // b8;  //9600   dc:19200
 123   1      //    T2CON=0x30;
 124   1      
 125   1          us100_cnt = 10;
 126   1          adready = 0;
 127   1       //   rececnt = WithOutComConst;
 128   1      
 129   1          LED1R = 1;
 130   1          LED2R = 1;
 131   1          LED1G = 1;
 132   1          LED2G = 1;
 133   1      
 134   1          ET0=1;
 135   1          TR0=1;
 136   1      //    TR2 = 1;
 137   1      //    ES=1;
 138   1          EA=1;
 139   1          count1 = 0;
 140   1      
 141   1      
 142   1      
 143   1      while (1)
 144   1       {
 145   2      
 146   2      /*   if (rfin)
 147   2          {
 148   2            address = ((~P1)>>2)&0xf;
 149   2      //      if (rbuf[1]!=address) {rfin = 0; continue;};
 150   2            j=start_byte;
 151   2            rece_p=&rbuf+1;
 152   2            for (i=0;i<12;i++)
 153   2             {j+=(*rece_p);
 154   2              if (*rece_p++==end_byte)
 155   2                if (*rece_p==j) {i=0; rfin = 0; break;}
 156   2             }
 157   2            rececnt = WithOutComConst;
 158   2            if (i==0)
 159   2             { // check right ,process.
 160   2               if (rbuf[2]==0x80) {
 161   2                   TRE485 = 1;
 162   2                   if (rbuf[3]==0xaa) Led1 = 0;
 163   2                   else Led1 = 1;
 164   2                   if (rbuf[4]==0xaa) Led3 = 0;
 165   2                   else Led3 = 1;
 166   2                   if (rbuf[5]==0xaa) Led2 = 0;
 167   2                   else Led2 = 1;
 168   2                   if (rbuf[6]==0xaa) Led4 = 0;
 169   2                   else Led4 = 1;
 170   2                   tbuf[0] = 0xca;
 171   2      
 172   2                   tbuf[1] = ad_buf[4];
 173   2                   tbuf[2] = ad_buf[1];
 174   2                   tbuf[3] = ad_buf[2];
 175   2                   tbuf[4] = ad_buf[3];
 176   2      
 177   2                   tbuf[5] = ad_buf[6];
 178   2                   tbuf[6] = ad_buf[5];
 179   2      
C51 COMPILER V7.50   SUIDAO1                                                               09/26/2007 09:17:54 PAGE 4   

 180   2                   tbuf[7] = Status[0];
 181   2                   tbuf[8] = Status[1];
 182   2                   tbuf[9] = Status[2];
 183   2                   tbuf[10] = Status[3];
 184   2      
 185   2                   tbuf[11] = 0xcc;
 186   2                   tran_p=tbuf;
 187   2                   tran_len=11;
 188   2                   tsta=1;
 189   2                   comm_gap=10;
 190   2                   SBUF=*tran_p;
 191   2               }
 192   2               rfin = 0;
 193   2             }//end of check right &
 194   2          }//end of rfin
 195   2      */
 196   2        if (t10ms)
 197   2           {
 198   3            // if (--comm_gap==0)
 199   3            //    rsta=0;
 200   3              t10ms=0;
 201   3             ad_buf[adchannel] = read_ad();
 202   3      
 203   3      
 204   3             adchannel++;
 205   3             adchannel &= 7;
 206   3      //       if (adchannel>5) adchannel = 0;
 207   3             P2 &= 0x1f;
 208   3             P2 |= ADMASK[adchannel];//4051ABC状态
 209   3      
 210   3      
 211   3           } // end of commgap
 212   2        if(ad_buf[5]>50)
 213   2        {
 214   3          count1++;
 215   3          if(count1>=3) OutStatus = 0xf0;
 216   3        }
 217   2        else
 218   2        {
 219   3        count1 = 0;
 220   3        if (t100ms) {
 221   4      
 222   4      //      CS_5045 = 0;
 223   4      //      CS_5045 = 1;
 224   4            t100ms = 0;
 225   4                /*if(flag2 ==0 )
 226   4                      {
 227   4                              count1++;
 228   4                              if( count1 >=7 )
 229   4                              flag1 = 0;
 230   4                              else
 231   4                              flag1 = 1;
 232   4                              if (count1 >10)
 233   4                              count1 = 0;
 234   4                              flag2 = 1;
 235   4                       }
 236   4                */
 237   4                instate = ~(P2|0Xf8);
 238   4                switch (instate)
 239   4                {
 240   5                      case 0x00:

⌨️ 快捷键说明

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