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

📄 beicheng2r.lst

📁 基于89c2051开发的ptr8000一对多无线通信程序.
💻 LST
字号:
C51 COMPILER V6.23a  BEICHENG2R                                                            11/20/2006 09:18:11 PAGE 1   


C51 COMPILER V6.23a, COMPILATION OF MODULE BEICHENG2R
OBJECT MODULE PLACED IN beicheng2r.OBJ
COMPILER INVOKED BY: C:\KEIL\C51\BIN\C51.EXE beicheng2r.c BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1          #define COMRBUFFLEN 16
   2          #include <reg51.h>
   3          #include <stdio.h>
   4          bit triggle=0,startframe=0,com2rb=1,lastcom2rb=1,lastdirection=1,direction1=0,direction2=1,direction=0;
   5          unsigned char TLV=0xb0;      //Now is 16 times of baud,0xc0; //for 18432000,4 times baudrate,
   6          unsigned char THV=0xff;      //                        0xfe; if 8times baudrate it's 0x60 and 0xff respect
             -ively.
   7          unsigned char com2sbufp=0,com2buffs[2],com2buffr[COMRBUFFLEN],com2buffrp=0;
   8          unsigned short SECTICKS=19200; //4800; //65536/(65536-(THV*256+TLV))*18;
   9          unsigned short HALFSECTICKS=9600; //2400;
  10          unsigned char rbuff[COMRBUFFLEN],sbuff[10];
  11          unsigned char rbuffp=0;
  12          unsigned char oldP1Stat,chno=0,ensend=0,rest;
  13          unsigned char ticks=0;ticks1=0,ticks2=0,ticksl2=0,ticksh2=0,ticks3,numberofzero=0,numberofone=16;
  14          unsigned char temptl0,tempth0;
  15          unsigned short filterB=0xffff,count=0,count1=0,com2sbuf;
  16          //sbit P32 = P3^2;
  17          sbit COM2R=P3^2; //P3^0;
  18          sbit COM2S=P3^1;
  19          sbit PULSE=P1^4;
  20          sbit DIRECTION=P1^5;
  21          sbit GLED=P1^3;
  22          void delay()
  23          {
  24   1       unsigned short i,j;
  25   1       for(i=0;i<30;i++) j=i;
  26   1      }
  27          void e0int() interrupt 0
  28          {
  29   1       P1=P1 ^ 0x80; // Feed watchdog.
  30   1       ticks3++;
  31   1      }
  32          void e1int() interrupt 2
  33          {
  34   1       ticks1++;
  35   1      }
  36          void t0int() interrupt 1
  37          {
  38   1       // unsigned char i;
  39   1       temptl0=TL0;
  40   1       tempth0=TH0;
  41   1       TH0=THV+tempth0;
  42   1       TL0=TLV+temptl0+10;
  43   1       //if(!(filterB&0x8000)) numberofzero--;
  44   1       /*No need following code to simulate com2,because of now we use indeed serial.
  45   1       filterB<<=1;
  46   1       filterB&=0xfffe;
  47   1       filterB|=COM2R;
  48   1       //if(!(filterB&1)) numberofzero++;
  49   1       switch (filterB&0x3f)
  50   1       {
  51   1        case 0x3f:
  52   1             com2rb=1;
  53   1                 break;
  54   1        case 0:
C51 COMPILER V6.23a  BEICHENG2R                                                            11/20/2006 09:18:11 PAGE 2   

  55   1             com2rb=0;
  56   1             if((!startframe)) // && (numberofzero>7)) // && (filterB&0xf)) // && (lastcom2rb) && (numberofzero>
             -=8))
  57   1                 {
  58   1                  startframe=1;
  59   1                  com2sbufp=0;
  60   1                  rest=count&0xf;
  61   1                 }
  62   1                 break;
  63   1        default:
  64   1             break;
  65   1       }
  66   1       lastcom2rb=com2rb;
  67   1       if(startframe && ((count&0xf) == rest))
  68   1       {
  69   1        com2sbuf>>=1;
  70   1        com2sbuf&=0xfeff;
  71   1        if(com2rb) com2sbuf|=0x0100;
  72   1        com2sbufp++;
  73   1        if(com2sbufp==10)
  74   1        {
  75   1         startframe=0;
  76   1         if(com2sbuf&0x100)
  77   1         {
  78   1          com2buffr[com2buffrp]=com2sbuf;
  79   1              //SBUF=com2sbuf;
  80   1              if((com2buffr[com2buffrp] == 'E') && (com2buffr[(com2buffrp+19)%COMRBUFFLEN] == 0) && (com2buffr[(com2buf
             -frp+16)%COMRBUFFLEN] == 'S'))
  81   1          {
  82   1               //TI=0;
  83   1           //SBUF=com2buffr[(com2buffrp+17)%COMRBUFFLEN];
  84   1               sbuff[4]=com2buffr[(com2buffrp+17)%COMRBUFFLEN];
  85   1               sbuff[5]=com2buffr[(com2buffrp+18)%COMRBUFFLEN];
  86   1              }
  87   1          if(++com2buffrp==COMRBUFFLEN) com2buffrp=0;
  88   1         }
  89   1        }
  90   1       }
  91   1       */ //End of simulate com2.
  92   1       
  93   1       if((count & 0x7f) == 0) // Sample P1 150 times per 1 second. do following things.
  94   1       {
  95   2        if ((oldP1Stat&0x10)==0x10 && (P1&0x10)==0x00) //DOWN triggle.
  96   2        {
  97   3         if ((P1&0x20)==0x20) direction1=1;
  98   3         else direction1=0;
  99   3        }
 100   2        if ((oldP1Stat&0x20)==0x20 && (P1&0x20)==0x00) //DOWN triggle.
 101   2        {
 102   3         if ((P1&0x10)==0x10) direction2=1;
 103   3         else direction2=0;
 104   3        }
 105   2        if(direction1 && !direction2) direction=1;
 106   2        if(!direction1 && direction2) direction=0;
 107   2        if((oldP1Stat^P1) & 0x10) ticks++;
 108   2        if((oldP1Stat^P1) & 0x20) ticks++;
 109   2        oldP1Stat=P1;
 110   2       }
 111   1       //if(DIRECTION!=lastdirection) ticks++;
 112   1       //lastdirection=DIRECTION;
 113   1       count++;
 114   1       if(count == HALFSECTICKS)
C51 COMPILER V6.23a  BEICHENG2R                                                            11/20/2006 09:18:11 PAGE 3   

 115   1       {
 116   2        triggle=1;
 117   2       }
 118   1       if(count == SECTICKS)
 119   1       {
 120   2        sbuff[6]=P1;
 121   2        sbuff[7]=ticks;
 122   2        if (direction) sbuff[6]=sbuff[6] | 0x20;
 123   2        else sbuff[6]=(sbuff[6] & 0xDF);
 124   2        ticks=0;
 125   2        count=0;
 126   2        triggle=1;
 127   2       }
 128   1       count1++;
 129   1       if(count1==HALFSECTICKS/2)
 130   1       {
 131   2        GLED=1; //LED is off
 132   2       }
 133   1      }
 134          void comint() interrupt 4
 135          {
 136   1       if(RI)
 137   1       {
 138   2        RI=0;
 139   2        rbuff[rbuffp]=SBUF;
 140   2        //if((rbuff[rbuffp] == 'E') && (rbuff[(rbuffp+COMRBUFFLEN-4)%COMRBUFFLEN] == 'S') && (rbuff[(rbuffp+COMR
             -BUFFLEN-1)%COMRBUFFLEN] == 0x00))
 141   2        if((rbuff[(rbuffp+COMRBUFFLEN-5)%COMRBUFFLEN] == 0x06) && (rbuff[(rbuffp+COMRBUFFLEN-4)%COMRBUFFLEN] == 
             -'S') && (rbuff[(rbuffp+COMRBUFFLEN-1)%COMRBUFFLEN] == 0x00))
 142   2        {
 143   3         sbuff[4]=rbuff[(rbuffp+COMRBUFFLEN-3)%COMRBUFFLEN];
 144   3         sbuff[5]=rbuff[(rbuffp+COMRBUFFLEN-2)%COMRBUFFLEN];
 145   3         GLED=0; //GLED is on.
 146   3         count1=0;
 147   3        }
 148   2        rbuffp++;
 149   2        if(rbuffp == COMRBUFFLEN) rbuffp=0;
 150   2       }
 151   1      }
 152          void main (void)
 153          {
 154   1       unsigned char i;
 155   1       sbuff[0]=0xff; 
 156   1       sbuff[1]=0xd7;
 157   1       sbuff[2]=0x08;
 158   1       sbuff[3]='S';
 159   1       sbuff[8]=0x00;
 160   1       sbuff[9]='E';
 161   1       SCON  = 0x50;                  /* SCON: mode 1, 8-bit UART, enable rcvr      */
 162   1       TMOD |= 0x21;               /* TMOD: timer 1, mode 2, 8-bit reload        */
 163   1       TH1   = 0xfb; //0x9600bps,0xd8;                /* TH1:  reload value for 1200 baud @ 184320000MHz   */
 164   1       TR1   = 1;                  /* TR1:  timer 1 run                          */
 165   1       IT1   = 1;
 166   1       IT0   = 1;
 167   1       TI    = 1;                  /* TI:   set TI to send first char of UART    */
 168   1       TR0   = 1;
 169   1       IE    = 0x92;     //enable Serial and t0 interrupt.
 170   1       while (1)
 171   1       {
 172   2        if (triggle==1)
 173   2        {
 174   3         //P32=0;
C51 COMPILER V6.23a  BEICHENG2R                                                            11/20/2006 09:18:11 PAGE 4   

 175   3         for(i=0;i<10;i++) putchar(sbuff[i]);
 176   3         //putchar(temptl0);
 177   3         triggle=0;
 178   3         //P32=1;
 179   3        }
 180   2        delay();
 181   2       }
 182   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    432    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =     82       3
   IDATA SIZE       =   ----    ----
   BIT SIZE         =      8    ----
END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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