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

📄 working.lst

📁 Main program running when workpiece is ready on deferent belt(deferent_ready=ture). * Call Squ
💻 LST
📖 第 1 页 / 共 2 页
字号:
 184          */
 185          
 186          void Initial_Timer0()
 187          {
 188   1              TMOD=   (TMOD|0x0f)&0xf2;                               // initialize Timer0 mode 2
 189   1              TL0 =   0x20;                                   //TL0 = 0x12;
 190   1              TH0 =   0x20;
 191   1      }
 192          
 193          
 194          /*$PAGE*/
 195          /*
 196          **********************************************************************************************************
             -********
 197          *                                      INTERRUPT SUBROUTINE
 198          * Description: none
 199          *
 200          * Arguments  : none
 201          *
 202          * Returns    : none
 203          **********************************************************************************************************
             -*******
 204          */
 205          void timer0(void) interrupt 1 using 1
 206          {
 207   1              P1_0 =! P1_0;                   // reverse P1_2
 208   1              intcounter++ ;
 209   1      }
 210          
 211          /*$PAGE*/
 212          /*
 213          ****************************************************************************************************
 214          *                                                                               DELAY SUBROUTINE
 215          * Description: delay
 216          *
 217          * Arguments  : none
 218          *
 219          * Returns    : none
 220          *****************************************************************************************************
 221          */
 222           void delay(){
 223   1              unsigned int i;
 224   1              for(i=0;i<=2;i++);
 225   1      }
 226          /*$PAGE*/
 227          
C51 COMPILER V7.07   WORKING                                                               09/25/2006 10:39:22 PAGE 5   

 228          
 229          /*
 230          **********************************************************************************************************
             -********
 231          *                                      A/D
 232          * Description: none
 233          *
 234          * Arguments  : none
 235          *
 236          * Returns    :
 237          **********************************************************************************************************
             -*******
 238          */
 239          void  A_D(void)
 240           {
 241   1               INT16U i,AD,AD_SUM=0 ;
 242   1               INT8U  ADHI,ADLO;
 243   1          for(i=0;i< AD_SIZE; i++ )
 244   1             {
 245   2              write = 0;
 246   2              ADCOM = AD_8EAB;                /*RC=0;A0=0;CS=0 enable 12 bit switch  */
 247   2              while(adbusy==1);
 248   2              read=0;
 249   2              ADCOM = AD_READH;               /*RC=1;A0=0;CS=0 enable high 8 bit out */
 250   2              ADHI  = P0;
 251   2              ADCOM = AD_READL;               /*RC=1;A0=1;CS=0 enable low 4 bit out  */
 252   2              ADLO  = P0;
 253   2              read  = 1;
 254   2              write = 1;
 255   2              CS    = 1;
 256   2              AD=ADHI*16+ADLO/16;
 257   2              AD_SUM+=AD ;
 258   2             }
 259   1              send[0]=0x0ad ;
 260   1              send[1]=k;
 261   1              send[2]=(AD_SUM/AD_SIZE)%256;
 262   1              send[3]=(AD_SUM/AD_SIZE)/256;
 263   1      
 264   1      }
 265          /*$PAGE*/
 266          /*
 267          **********************************************************************************************************
             -********
 268          *                                      SERIAL SUBROUTE
 269          * Description: none
 270          
 271          * Arguments  : none
 272          *
 273          * Returns    : none
 274          **********************************************************************************************************
             -*******
 275          */
 276          void Serial_init(void)
 277          {            TMOD = (TMOD|0xf0)&0x2f;                   // Timer1 Mode 1
 278   1                   TH1 = 0x0f3;                       // Baud 2400, 11.059 MHZ
 279   1                   TL1=0x0f3;
 280   1                   TR1=1;
 281   1                   SCON = 0x50;                       // Serial port Mode 1, enable receive and  send
 282   1                   EA=1;                              // Enable interrupt
 283   1                  // ES=1;
 284   1      }
 285          
C51 COMPILER V7.07   WORKING                                                               09/25/2006 10:39:22 PAGE 6   

 286          
 287          /*
 288          **********************************************************************************************************
             -***********
 289          *send data format:flag byte(0xad,AD valve(L),AD valve(H),checkout byte(wait reply 0x00 is correct flag)
 290          * after send 4 bytes,wait for pc reply,if pc receive correct flag byte and checkout byte,reply is 0x00,
 291          *else should send again
 292          
 293          */
 294          
 295          void  Serial_s(void)
 296          {
 297   1      
 298   1                   ES=0;                      // disable serial port interrupt
 299   1         do {
 300   2              INT8U k,pf=0;
 301   2              for(k=0;k<SEND_SIZE;k++ )
 302   2              {
 303   3                 SBUF=send[k];                        // transfer AD value to PC
 304   3                 pf+=send[k];
 305   3                 while(TI==0);
 306   3                 TI = 0;
 307   3                 delay();             // wait for Transfer Interrupt enable   , clear TI
 308   3               }
 309   2                 SBUF=pf;
 310   2                 while(TI==0);
 311   2                 TI = 0;
 312   2                 while(RI==0);
 313   2                 RI=0;                // wait for PC reply
 314   2              }while(SBUF!=0x52);             // PC transfer a flag to MCU if false then repeat
 315   1                ES=1;
 316   1      }
 317          
 318          /**************************************************************************************
 319          *format:flag byte 0x0aa(reply 0x00(true) or 0x0ff),step number(L),step number(h),checkout type(reply 0x00(
             -true) or 0x0ff)
 320          *receive flag word=0x0aa,answer 0x0aa,else answer 0x0ff  and return
 321          **receive motor step number
 322          **then receive checkout word,if correct,send 0x00,then Deferent_Ready=True and return.
 323          **else send 0x0ff,repeat receive motor step number
 324          ***************************************************************************************/
 325          
 326          void  Serial_sr(void)   interrupt 4 using 3
 327          {
 328   1         INT8U k,i,pf=0;
 329   1         INT8U srtemp ;
 330   1         ES=0;                                // disable serial port interrupt
 331   1            if(RI)
 332   1             {
 333   2                 srtemp=SBUF;
 334   2                 RI=0;
 335   2                 receive[r_start]=srtemp;
 336   2                 pf+=receive[r_start];
 337   2                 if(r_start<(RECE_SIZE-1))
 338   2                    {
 339   3                      r_start++;
 340   3                     }
 341   2                 else
 342   2                    {
 343   3                      r_start=0;
 344   3                         // if( (receive[0]-'c')||(receive[1]-'s')==0)
 345   3                          if( (receive[0]=='C')&& (receive[1]=='S') )
C51 COMPILER V7.07   WORKING                                                               09/25/2006 10:39:22 PAGE 7   

 346   3                           {
 347   4                             Deferent_Ready=True;          // deferent start
 348   4      
 349   4                               SBUF='R';                      // send correct flag to PC
 350   4                               while(TI==0);TI = 0;
 351   4                            }
 352   3                          else
 353   3                            {
 354   4                             SBUF='W';                        // send correct flag to PC
 355   4                             while(TI==0);
 356   4                             TI = 0;
 357   4                            }
 358   3      
 359   3                    }
 360   2           ES=1;                            //enable serial port interrupt
 361   2           }
 362   1          }
*** WARNING C280 IN LINE 328 OF WORKING.C: 'k': unreferenced local variable
*** WARNING C280 IN LINE 328 OF WORKING.C: 'i': unreferenced local variable


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    492    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      4       7
   IDATA SIZE       =     10    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  2 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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