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

📄 osc2_0929.lst

📁 基于485的51单片机多机通讯程序
💻 LST
📖 第 1 页 / 共 5 页
字号:
C51 COMPILER V7.06   OSC2_0929                                                             03/27/2006 17:02:25 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE OSC2_0929
OBJECT MODULE PLACED IN F:\NEWMACHINE\060123\DRIVE\OSC2_0929.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE F:\NEWMACHINE\060123\DRIVE\OSC2_0929.C DB SB OE

stmt level    source

   1          #include <OSC.h>
   2          sbit message_enable=P1^5;
   3          sbit stop=P3^5;
   4          sbit gate=P4^1;
   5          sbit osc_dir=P4^5;
   6          sbit osc_enable=P4^4;
   7          sbit osc_out=P4^6;
   8          
   9          xdata unsigned char  rbuffer[55]        _at_ 0x0200;
  10          unsigned char   S_ANSW,POINTER0,POINTER1,work,RSUM,SSUM,s_byte_nums,r_byte_nums,sbuffer[6],c_t1,
  11                          c_decrease,temp_c_decrease,share_decrease,osc_add,osc_dec,share,nonce_sec,c_t42,
  12                          c_t42_l,c_t42_r,err,p_sec,c_change,temp_c_change,cross_machine,c_cm1;
  13          unsigned char   COMM,SLA,FF,GET;
  14          unsigned int    delt_a41,*point,delt_out1,delt_out0,n_dc41,const1,n_da41;
  15          xdata unsigned long     out0,out1,out2,const0,const2,const3,temp_out1,static_out1,temp_out0,static_out0,
  16                                  out0_decrease,out1_decrease;
  17          
  18          bit     t_edge,osc_ok,decrease,decreased,stop_osc,new_sector,excursion_dir,
  19                  center_excursion,called,judge_ok,urgent_stop,in_sector,
  20                  start,over_i1,over_i2,resend,send,overtime,osc_l,osc_r,motor_stop,sec_change,
  21                  receive_p_out,receive_p_in,start_osc,ans,to_begin,decrease_ok,center_change,
  22                  need_para,osc_err,err_ok,breadth_add,breadth_dec,osc,osc_change,K4,sec_center;
  23          #define start_v 200;
  24          
  25          void start_i2()
  26          {
  27   1         data unsigned int time;
  28   1         P1_6=1;              //SCL
  29   1         P1_7=1;              //SDA
  30   1         S1CON=0x47;          //ENS1=1 STA=0 STO=0 SI=0 AA=1
  31   1         PS1=1;FF=0;
  32   1         EA=1;
  33   1         ES1=1;
  34   1         STA=1;
  35   1         time=0;
  36   1         do
  37   1           {
  38   2            time++;
  39   2            if(time>10000)
  40   2                {
  41   3                 FF=1;
  42   3                }
  43   2           }while(FF==0);
  44   1         FF=0;
  45   1         ES1=0;
  46   1      }
  47          
  48          void start_t2()
  49          {
  50   1              TM2CON=0x81;    //16位溢出,分频系数1,f/12
  51   1              EA=1;
  52   1              TM2IR=0;
  53   1      }
  54          
  55          void ini_sbuf(unsigned char a,b,c,d,e,f)
C51 COMPILER V7.06   OSC2_0929                                                             03/27/2006 17:02:25 PAGE 2   

  56          {
  57   1              sbuffer[0]=a;
  58   1              sbuffer[1]=b;
  59   1              sbuffer[2]=c;
  60   1              sbuffer[3]=d;
  61   1              sbuffer[4]=e;
  62   1              sbuffer[5]=f;
  63   1      }
  64          
  65          unsigned char get_byte_nums(unsigned char type)
  66          {
  67   1              unsigned char numbers;
  68   1              switch(type)
  69   1              {
  70   2                      case    infor_sec:
  71   2                      case    command:
  72   2                      case    program:
  73   2                      case    answer:         numbers=4;
  74   2                                              break;
  75   2                      case    err_infor:
  76   2                      case    parameter1:     numbers=5;
  77   2                                              break;
  78   2                      case    parameter:
  79   2                      case    infor:          numbers=6;
  80   2                                              break;
  81   2                      case    parameter2:     numbers=7;
  82   2                                              break;
  83   2                      case    call_result:    numbers=8;
  84   2                                              break;
  85   2                      case    p_out_sec:      numbers=55;
  86   2                                              break;
  87   2                      case    p_in_sec:       numbers=24;
  88   2                                              break;
  89   2                      case    edit_sec:       numbers=64;
  90   2                                              break;
  91   2                      default:                numbers=4;
  92   2                                              break;
  93   2              }
  94   1              return numbers;
  95   1      }
  96          
  97          void TR_noans()
  98          {
  99   1              POINTER0=0;
 100   1              SSUM=0;
 101   1              send=1;
 102   1              c_t1=0;
 103   1              message_enable=0;                               //开发送使能
 104   1              TR1=1;
 105   1              while(POINTER0<s_byte_nums);
 106   1              TR1=0;
 107   1              message_enable=1;                               //关发送使能
 108   1      }
 109          
 110          void TR_ans()
 111          {
 112   1              ans=1;
 113   1              REN=0;
 114   1              POINTER1=0;
 115   1              RSUM=0;
 116   1              TB8=1;
 117   1              POINTER0=0;
C51 COMPILER V7.06   OSC2_0929                                                             03/27/2006 17:02:25 PAGE 3   

 118   1              SSUM=0;
 119   1              send=1;
 120   1              c_t1=0;
 121   1              message_enable=0;                               //开发送使能
 122   1              TR1=1;
 123   1              while(POINTER0<s_byte_nums);
 124   1              TR1=0;
 125   1              message_enable=1;                               //关发送使能
 126   1      
 127   1              REN=1;
 128   1              send=0;
 129   1              c_t1=0;
 130   1      //      TR1=1;
 131   1              while(POINTER1<r_byte_nums&&overtime==0);
 132   1              TR1=0;
 133   1              if(overtime==1)
 134   1              {
 135   2                      err=3;
 136   2                      osc_err=1;
 137   2                      overtime=0;
 138   2              }
 139   1              ans=0;
 140   1      }
 141          
 142          void delay(int num)
 143          {
 144   1        data unsigned int i,j;
 145   1        for(i=0;i<num;i++)
 146   1         {
 147   2           for(j=0;j<255;j++);
 148   2         }
 149   1      }
 150          /*
 151          void read_8574 ()                       //过流1或过流2
 152          {
 153                  unsigned char temp_GET;
 154                  SLA=0x43;
 155                  start_i2();
 156                  temp_GET=GET;
 157                  temp_GET=temp_GET&0X01;
 158                  if(temp_GET==0)
 159                          over_i1=1;
 160                  temp_GET=GET;
 161                  temp_GET=temp_GET&0X02;
 162                  if(temp_GET==0)
 163                          over_i2=1;
 164          }
 165          */
 166          void write_8574(unsigned char col)      //出错显示
 167          {
 168   1              SLA=0x42;
 169   1              COMM=col;
 170   1              start_i2();
 171   1      }
 172          
 173          void com_type()
 174          {
 175   1              switch(rbuffer[2])
 176   1              {
 177   2                      case com_calling:       called=1;break;
 178   2                      case com_motor_stop:    motor_stop=1;break;
 179   2                      case com_start:         start=1;break;                  //启动
C51 COMPILER V7.06   OSC2_0929                                                             03/27/2006 17:02:25 PAGE 4   

 180   2                      case com_decrease:      {
 181   3                                                      if(osc_ok==1)
 182   3                                                      {
 183   4                                                              if(osc_add>osc_dec)
 184   4                                                              {
 185   5                                                                      delt_a41=pp.da41*(osc_add-osc_dec);
 186   5                                                                      const1=const1+delt_a41;
 187   5                                                              }
 188   4                                                              else if(osc_add<osc_dec)
 189   4                                                              {
 190   5                                                                      delt_a41=pp.da41*(osc_dec-osc_add);
 191   5                                                                      const1=const1-delt_a41;
 192   5                                                              }
 193   4                                                              if(in_sector==0)
 194   4                                                              {
 195   5                                                                      const0=pp.v41*pp.t17;
 196   5                                                                      const3=120*const1;
 197   5                                                                      const2=pp.t42_l+pp.t42_r;
 198   5                                                                      const2=const2*pp.v41;
 199   5                                                                      const3=const3+const2;
 200   5                                                              }
 201   4                                                              else if(osc_ok==1)
 202   4                                                              {
 203   5                                                                      const0=pp.x[nonce_sec][3]*pp.t17;
 204   5                                                                      const3=120*const1;
 205   5                                                                      const2=pp.x[nonce_sec][1]+pp.x[nonce_sec][2];
 206   5                                                                      const2=const2*pp.x[nonce_sec][3];
 207   5                                                                      const3=const3+const2;
 208   5                                                              }
 209   4                                                              c_decrease=const0/const3+1;
 210   4                                                              out1_decrease=out1;
 211   4                                                              out0_decrease=out0;
 212   4                                                              temp_c_decrease=1;
 213   4                                                              share_decrease=0;
 214   4                                                      }
 215   3                                                      decrease=1;
 216   3                                              }break;
 217   2                      case com_osc:           start_osc=1;break;                      //启动CT0
 218   2                      case com_osc_l:         {
 219   3                                                      if(work==0)                     //点动
 220   3                                                      {
 221   4                                                              if(osc_l==0)
 222   4                                                                      osc_l=1;
 223   4                                                      }
 224   3                                                      else
 225   3                                                      {
 226   4                                                              if(center_excursion==0&&judge_ok==0)

⌨️ 快捷键说明

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