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

📄 jiaotong.lst

📁 多功能数字交通灯设计
💻 LST
字号:
C51 COMPILER V8.02   JIAOTONG                                                              08/12/2008 17:09:27 PAGE 1   


C51 COMPILER V8.02, COMPILATION OF MODULE JIAOTONG
OBJECT MODULE PLACED IN jiaotong.OBJ
COMPILER INVOKED BY: E:\design tools\keilc\C51\BIN\C51.EXE jiaotong.c BROWSE DEBUG OBJECTEXTEND

line level    source

   1          #include <reg51.h>
   2          #include <stdio.h>
   3          #define uchar     unsigned char
   4          #define uint      unsigned int
   5          sbit key1=P3^2;
   6          sbit key2=P3^3;
   7          sbit key3=P3^4;
   8          sbit key4=P3^5;
   9          
  10          uchar h,count,num,dat,flag,dat1,num1,key1num,temp;
  11          uint r=0;
  12          uint s;
  13          uchar code  dis[]={
  14                                                                  
  15                  0Xc0,/*0*/
  16                  0Xf9,/*1*/
  17                  0Xa4,/*2*/
  18                  0Xb0,/*3*/
  19                  0X99,/*4*/
  20                  0X92,/*5*/
  21                  0X82,/*6*/
  22                  0Xf8,/*7*/
  23                  0X80,/*8*/
  24                  0X90,/*9*/
  25                  0Xff,/*NULL*/
  26          };
  27          
  28          
  29          void delay(uint c)
  30          {
  31   1         uint i,j;
  32   1          for(i=0;i<c;i++)
  33   1                for(j=0;j<100;j++);
  34   1              
  35   1      }
  36          
  37          void init()
  38          {
  39   1              TMOD=0x11;//设置定时器0为工作方式1
  40   1              TH0=(65536-10000)/256;
  41   1              TL0=(65536-10000)%256;
  42   1              TH1=(65536-20000)/256;
  43   1              TL1=(65536-20000)%256;
  44   1              EA=1;//开总中断
  45   1              ET0=1;//开定时器0中断
  46   1              ET1=1;
  47   1              TR0=1;//启动定时器0
  48   1              TR1=1;
  49   1              num=66;
  50   1      //      P0=0xeb;
  51   1      }
  52          void display(dat)   //送显示
  53          {                       
  54   1                              
  55   1                         if(dat<=33)
C51 COMPILER V8.02   JIAOTONG                                                              08/12/2008 17:09:27 PAGE 2   

  56   1                         {
  57   2                              if(dat>3&&dat<33)
  58   2                              {
  59   3                                      P0=0xdd;//红灯
  60   3                                      P1=0x00;
  61   3                              P2=0xff;
  62   3                              P1=0x01;
  63   3                              P2=dis[dat/10];
  64   3                               delay(1);
  65   3                                      P1=0x00;
  66   3                              P2=0xff;
  67   3                              P1=0x02;
  68   3                              P2=dis[dat%10];
  69   3                                       delay(1);
  70   3                                      P1=0x00;
  71   3                              P2=0xff;
  72   3                                      P1=0x04;
  73   3                              P2=dis[(dat-3)/10];
  74   3                                       delay(1);
  75   3                                      P1=0x00;
  76   3                              P2=0xff;
  77   3                                      P1=0x08;
  78   3                              P2=dis[(dat-3)%10];
  79   3                               delay(1);
  80   3                                }
  81   2                               if(dat<=3)
  82   2                               {
  83   3                                              P0=0xd4;//黄灯
  84   3                                              P1=0x00;
  85   3                                      P2=0xff;
  86   3                                      P1=0x02;
  87   3                                      P2=dis[dat%10];
  88   3                                              delay(1);
  89   3      
  90   3                                              P1=0x00;
  91   3                                          P2=0xff;
  92   3                                          P1=0x08;
  93   3                                          P2=dis[(dat-3)%10];
  94   3                                          delay(1);
  95   3                                              
  96   3                                                      
  97   3                               }
  98   2      //                       break;
  99   2                              }
 100   1      
 101   1                              if(dat>=33&&dat<=66)
 102   1                              {
 103   2                              if(dat>36&&dat<=66)
 104   2                              {
 105   3                                      P0=0xeb;
 106   3                                                      P1=0x00;
 107   3                              P2=0xff;
 108   3                              P1=0x01;
 109   3                              P2=dis[(dat-33)/10];
 110   3                               delay(1);
 111   3                                      P1=0x00;
 112   3                              P2=0xff;
 113   3                              P1=0x02;
 114   3                              P2=dis[(dat-33)%10];
 115   3                                       delay(1);
 116   3                                      P1=0x00;
 117   3                              P2=0xff;
C51 COMPILER V8.02   JIAOTONG                                                              08/12/2008 17:09:27 PAGE 3   

 118   3                                      P1=0x04;
 119   3                              P2=dis[(dat-36)/10];
 120   3                                       delay(1);
 121   3                                      P1=0x00;
 122   3                              P2=0xff;
 123   3                                      P1=0x08;
 124   3                              P2=dis[(dat-36)%10];
 125   3                               delay(1);      
 126   3                               }
 127   2                               if(dat>=33&&dat<=36)
 128   2                               {
 129   3                                              P0=0xe2;//黄灯
 130   3                                              P1=0x00;
 131   3                                      P2=0xff;
 132   3                                      P1=0x02;
 133   3                                      P2=dis[(dat-33)%10];
 134   3                                              delay(1);          
 135   3      
 136   3                                              P1=0x00;
 137   3                                          P2=0xff;
 138   3                                          P1=0x08;
 139   3                                          P2=dis[(dat-33)%10];
 140   3                                          delay(1);     
 141   3                               }
 142   2      //                       break;
 143   2                              }
 144   1                               
 145   1      }
 146          void keyscan() //键盘检测
 147          {
 148   1              if(key1==0)
 149   1              {
 150   2                      delay(5);
 151   2                      if(key1==0)
 152   2                      {
 153   3                              key1num++;
 154   3                              while(!key1)
 155   3                              {
 156   4                                      display(num);
 157   4                              }
 158   3                              if(key1num==1)
 159   3                              {
 160   4                                      TR0=0;
 161   4                                      TR1=0;
 162   4                              }
 163   3                              if(key1num==2)
 164   3                              {
 165   4                                      TR0=1;
 166   4                                      TR1=1;
 167   4                                      P1=temp;
 168   4                                      key1num=0;
 169   4      
 170   4                              }
 171   3                      }
 172   2              
 173   2              }
 174   1                      if(key1num!=0)
 175   1                      {       
 176   2                              if(key2==0)
 177   2                              {
 178   3                                      delay(5);
 179   3                                      if(key2==0)
C51 COMPILER V8.02   JIAOTONG                                                              08/12/2008 17:09:27 PAGE 4   

 180   3                                      {
 181   4                                              while(!key2)
 182   4                                              {
 183   5                                                      display(num);
 184   5                                              }
 185   4                                              if(key1num==1)
 186   4                                              {
 187   5                                                      num++;
 188   5                                                      display(num);
 189   5                                                      
 190   5                                              }
 191   4                                              if(key1num==2)
 192   4                                              {
 193   5                                                      num++;
 194   5                                                      display(num);
 195   5                                              }
 196   4                                      }
 197   3                              }
 198   2                          if(key3==0)
 199   2                              {
 200   3                                      delay(5);
 201   3                                      if(key3==0)
 202   3                                      {
 203   4                                              while(!key3)
 204   4                                              {
 205   5                                                      display(num);
 206   5                                              }
 207   4                                              
 208   4                                                      if(key1num==1)
 209   4                                                      {
 210   5                                                              if(num==0)
 211   5                                                              num=32;
 212   5                                                              num--;
 213   5                                                      }
 214   4                                              
 215   4      
 216   4                                      }
 217   3                              }
 218   2                      }
 219   1      }
 220          void main()  //主函数
 221          {
 222   1              init();
 223   1              while(1)
 224   1              {       
 225   2                      keyscan();
 226   2                      if(count==10)
 227   2                      {
 228   3                              count=0;
 229   3                              num--;
 230   3                              
 231   3                              if(num==0)
 232   3                              {
 233   4                                      num=66;
 234   4                              }
 235   3                      }
 236   2                      display(num);
 237   2              }
 238   1      }
 239          void t0(void ) interrupt 1  //定时器T0
 240          {
 241   1              TH0=(65535-50000)/256;
C51 COMPILER V8.02   JIAOTONG                                                              08/12/2008 17:09:27 PAGE 5   

 242   1              TL0=(65535-50000)%256;
 243   1              count++;
 244   1              num1++; 
 245   1      
 246   1              
 247   1      }
 248          void time1() interrupt 3        //定时器T1
 249          {
 250   1              TH1=(65536-20000)/256;
 251   1              TL1=(65536-20000)%256;
 252   1      
 253   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    696    ----
   CONSTANT SIZE    =     11    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =     13       2
   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 + -