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

📄 systhree.lst

📁 省电子竞赛做品
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V8.05a   SYSTHREE                                                             06/29/2007 12:36:53 PAGE 1   


C51 COMPILER V8.05a, COMPILATION OF MODULE SYSTHREE
OBJECT MODULE PLACED IN Systhree.OBJ
COMPILER INVOKED BY: D:\Program Files\keil\C51\BIN\C51.EXE Systhree.C BROWSE DEBUG OBJECTEXTEND

line level    source

   1          /*********************************************************/
   2          /**                                                     **/
   3          /**                作者:jia                                                    **/
   4          /**                时间:2007/6/6                       **/
   5          /**        National University of Defence Technology    **/
   6          /**                   0731-4573493                      **/
   7          /*********************************************************/
   8          
   9          #include <absacc.h>
  10          #include <reg52.h>
  11          #include<intrins.h>
  12          
  13          #define uchar unsigned char
  14          #define uint8 unsigned char
  15          #define uint16 unsigned int
  16          
  17          #define LED8 XBYTE [0xA000]   //数码管地址
  18          #define LED7 XBYTE [0xA001]
  19          #define LED6 XBYTE [0xA002]
  20          #define LED5 XBYTE [0xA003]
  21          #define LED4 XBYTE [0xA004]
  22          #define LED3 XBYTE [0xA005]
  23          #define LED2 XBYTE [0xA006]
  24          #define LED1 XBYTE [0xA007]
  25          
  26          #define YD_INTERNAL 5
  27          
  28          
  29          
  30          #define KEY XBYTE [0xA100]  //键盘地址
  31          
  32          
  33          /*扫描键盘使用的变量 */
  34          sbit first_row = P1^4;      //键盘第一行控制
  35          sbit second_row = P1^3;     //键盘第二行控制
  36          bit first_getkey = 0,control_readkey = 0;  //读键盘过程中的标志位
  37          bit getkey = 0; //获得有效键值标志位 等于1时代表得到一个有效键值
  38          bit keyon = 0;  //防止按键冲突标志位
  39          uchar keynum = 0;  //获得的有效按键值寄存器
  40          
  41          uchar T2count = 0; 
  42          bit MotorStart=0; //启动电机控制
  43          sbit MotorForward = P1^0;
  44          sbit MotorBack = P1^1;
  45          sbit P1_2 = P1^2; // 外接蜂鸣器报警
  46          sbit P1_6 = P1^6; // #RE
  47          sbit P1_7 = P1^7; // DE  MAX487    发送前7置1,接受前6\7置0
  48          sbit P1_5 = P1^5; // 液滴调试用
  49          
  50          
  51          
  52          uchar Vset = 255;
  53          uchar Vnow  = 75;
  54          uint16 MotorTimer = 100 ;
  55          uint16 circle = 0;
C51 COMPILER V8.05a   SYSTHREE                                                             06/29/2007 12:36:53 PAGE 2   

  56          uint16 Vnow100 = 7500;
  57          uchar NOset = 16;               //设置的从站号
  58          
  59          
  60          
  61          // 系数
  62          #define COEF 105 //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
  63          #define HEIGHT0 100 // 初始高度1m,系数1.67
  64          #define V_INITIAL0 78 // 初始液滴速度 78 t/min
  65          #define MotorV 137 // 电机速度,50cm/s           86cm/63s
  66          #define CIRCLE 20
  67          
  68          
  69          uchar state = 0  ;
  70          bit alarm =0;
  71          bit direction=0;// 0 represent move down
  72          uint16  temV = 0; 
  73          uint16 num      =0;
  74          uchar    icount[6] = {0} ;
  75          uint16 i         = 0;
  76          uchar    vh      =0;
  77          uchar    vl      =0;
  78          uint16 HMove;
  79          
  80          uchar num_yt=0;
  81          uchar num_yd_actual=0;
  82          
  83          /*数码管显示使用的变量和常量*/
  84          uchar lednum = 0;  //数码管显示位控制寄存器
  85          uchar led[8] = {0,0,0,0,0,0,0,0};  //数码管显示内容寄存器
  86          uchar code segtab[18] = {0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e,0
             -x8c,0xff}; //七段码段码表
  87                                // "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "
             -P" ,"black" 
  88          
  89          void leddisp(void); //数码管显示函数
  90          void readkey(void); //读键盘函数
  91          void setvalue (unsigned char keynum);
  92           
  93          void  delay(uint8 time_nop);
  94          void SetMotorTimeT2();
  95          void sendBuf();
  96          //************************************************************************************************
  97          //***********************************************************************************************
  98          //定时器T0是用方式三,低八位用来定时4ms,LED 显示和键盘扫描
  99          
 100          void intTL0() interrupt 1 //TL0 定时中断处理函数
 101          {
 102   1           static uchar TL0_i = 0;   // 定义静态变量,用来计数TL0定时器的溢出次数(进入本函数的次数)
 103   1           static uchar TL0_j = 0;   // 定义静态变量,用来计数intr1定时器的延迟(进入本函数的次数)
 104   1               TL0 = -2720%256;
 105   1           if(TL0_i++ == 11)//定时器中断时间间隔 4ms
 106   1               { 
 107   2                      TL0_i = 0;
 108   2                      leddisp();  //每次定时中断显示更新一次
 109   2              if(EX1 == 0 && TL0_j++ >= YD_INTERNAL) 
 110   2                      {
 111   3                              EX1 = 1;
 112   3                  TL0_j = 0;
 113   3                      }
 114   2                      if(control_readkey == 1)  //每两次定时中断扫描一次键盘
 115   2                      {
C51 COMPILER V8.05a   SYSTHREE                                                             06/29/2007 12:36:53 PAGE 3   

 116   3                      readkey();
 117   3                      }
 118   2                  control_readkey = !control_readkey;
 119   2       
 120   2              if(MotorStart==1)
 121   2              {
 122   3                      if(T2count == MotorTimer || Vnow>=Vset-2 && Vnow<=Vset+2)       //|| Vnow>Vset-5 && Vnow<Vset+5
 123   3                      {
 124   4                              MotorStart=0;
 125   4                              MotorForward=0;
 126   4                              MotorBack=0;
 127   4                              T2count=0;
 128   4                              Vnow=Vset;
 129   4                              Vnow100 = 100*Vnow;     
 130   4                      }
 131   3                      else
 132   3                      {
 133   4                          if(Vset >= Vnow) direction =  1;    
 134   4                         else direction = 0;
 135   4                              if(!direction)
 136   4                              {
 137   5                                      MotorBack=1;
 138   5                                      MotorForward=0;
 139   5                              }
 140   4                              else 
 141   4                              {
 142   5                                      MotorForward=1;
 143   5                                      MotorBack=0;
 144   5                              }
 145   4                      }                               
 146   3        }
 147   2        else
 148   2        {
 149   3                MotorStart=0;
 150   3                MotorForward=0;
 151   3            MotorBack=0;
 152   3                T2count=0;
 153   3        }
 154   2      }
 155   1      }
 156          
 157          //*************************************外部中断1**********************************************************
             -***
 158          //********************************************************************************************************
             -*********************
 159          
 160          // 点滴信号检测,置P1_5口为1,触发发光二极管点亮一段时间
 161          // 外部中断1,用来接收LM567音频锁相环的点滴信号(低电平)
 162          // 内置计数器,根据定时器T0定时中断,计数后放入icount[i]数组
 163          void intr1_serve (void )interrupt 2
 164          {
 165   1          //static  uchar intr1_i = 0;
 166   1      
 167   1      
 168   1          EX1 = 0;
 169   1              P1_5 = ~ P1_5;
 170   1              num_yt+=1;
 171   1              num_yd_actual=num_yt/2;
 172   1      
 173   1      }
 174          //************************************************************************************************
 175          
C51 COMPILER V8.05a   SYSTHREE                                                             06/29/2007 12:36:53 PAGE 4   

 176          //*************************************外部中断0**********************************************************
             -***
 177          //********************************************************************************************************
             -*********************
 178          
 179          
 180          void intr0_serve (void )interrupt 0
 181          {
 182   1        alarm = 1;
 183   1      }
 184          //************************************************************************************************
 185          
 186          //********************************************************************************************************
             -*********************
 187          
 188          // 由于T0采用工作方式3,所以T1只能用作串口波特率发生器
 189          // 注意:从站Fsoc=12MHz,主站Fsoc=24MHz,只需将波特率设置相同即可
 190          // 此时,TH0占用TF1,所以此中断处理程序是处理T0的TH0的,定时器T0占用TF1,相当于T1中断
 191          // 最大定时周期为256us
 192          void time2_serve (void)interrupt 5
 193          {   
 194   1      
 195   1              static  uchar  Vn100 = 0;
 196   1          static uchar T2_i = 0;   // 定义静态变量,用来计数TL0定时器的溢出次数(进入本函数的次数)
 197   1          static  uchar j = 0;
 198   1              static  uchar test_circle = 0;
 199   1              TF2 = 0;                                  
 200   1              if( T2_i++ == 8 )                        //0.5S
 201   1              {
 202   2                      T2_i = 0 ;
 203   2              T2count++ ;
 204   2      
 205   2      
 206   2                      if( test_circle++ == 20 ) // total count to 10s
 207   2                      {
 208   3                              // 把外部跳变数发到icount[i]
 209   3                              icount[i%6]=num_yd_actual;
 210   3                              i++;
 211   3                              // 将外部中断计数清0
 212   3                              num_yd_actual=0;
 213   3                              test_circle = 0;
 214   3                      }
 215   2      
 216   2                      // 每十秒更新一次速度
 217   2                      if(i>=6)
 218   2                      {
 219   3                              Vnow=0;
 220   3                              Vnow100=0;
 221   3      
 222   3                              for(j=0;j<6;j++)
 223   3                              {
 224   4                                      Vnow+=icount[(i-j)%6];
 225   4                                      Vnow100 = 100*Vnow;
 226   4                              }
 227   3                              if(i==6)
 228   3                                      vh=Vnow;
 229   3                              if(i==12)
 230   3                                      vl=Vnow;
 231   3                      }
 232   2              }
 233   1              if( Vn100++ == 16 )
 234   1              {
C51 COMPILER V8.05a   SYSTHREE                                                             06/29/2007 12:36:53 PAGE 5   

 235   2                      Vn100 = 0;
 236   2                      if(direction == 0 && MotorStart==1)
 237   2                      {
 238   3                              Vnow100 -= 131;
 239   3                      }
 240   2                      else if (direction == 1 && MotorStart==1)
 241   2                      {
 242   3                               Vnow100 += 131;
 243   3      
 244   3                      }
 245   2      
 246   2              }
 247   1      }
 248          //********************************************************************************************************
             -*********************
 249          //********************************************************************************************************
             -*********************
 250          // end of time1
 251          //**************************************************************************************************
 252          //************************************************************************************************
 253          void ps_serve (void )interrupt 4
 254          {  
 255   1         static wait = 0;
 256   1         if(RI == 1)
 257   1         {
 258   2                uchar a = 0,b = 0;
 259   2            P1_6 = 0;
 260   2            P1_7 = 0;
 261   2                a = SBUF;
 262   2                P1_7 = 1;
 263   2                b = a & 0x0F;
 264   2                RI = 0;
 265   2                if(a >= 192 && b == NOset)
 266   2                {                             
 267   3                   sendBuf();
 268   3      
 269   3                       wait = 1;
 270   3                       if( a >= 208) 
 271   3                        alarm =0;
 272   3                }
 273   2                else
 274   2                {
 275   3                  if(wait == 1)
 276   3                      {
 277   4                              if(a>=20 && a<=150)
 278   4                              {
 279   5                                      Vset = a;
 280   5                                      SetMotorTimeT2();
 281   5                              }
 282   4                              P1_7 = 1;
 283   4                              SBUF = Vnow100/100;
 284   4                              P1_6 = 0;
 285   4                  P1_7 = 0;
 286   4                              wait = 0;
 287   4                      }
 288   3                
 289   3                }
 290   2         }
 291   1         else TI = 0;
 292   1      
 293   1      }
 294          
C51 COMPILER V8.05a   SYSTHREE                                                             06/29/2007 12:36:53 PAGE 6   

⌨️ 快捷键说明

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