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

📄 main.lst

📁 博世加速度传感器程序,代码进行了参数设置
💻 LST
字号:
C51 COMPILER V7.06   MAIN                                                                  04/18/2008 12:26:28 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE main.C BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1          #include "reg51.h" 
   2          #include "intrins.h"
   3          
   4          //引脚定义
   5          sbit  CSB               =       P3^5;
   6          sbit  SDI               =       P3^2;
   7          sbit  SDO               =       P3^3;                   
   8          sbit  SCK               =       P3^4;
   9          
  10          /* 变量定义 */
  11          unsigned char   bdata   control1=0;
  12          sbit    sleep           =       control1^0;
  13          sbit    soft_reset      =       control1^1;
  14          sbit    self_test0      =       control1^2;
  15          sbit    self_test1      =       control1^3;
  16          sbit    ee_w            =       control1^4;
  17          sbit    update_image=   control1^5;
  18          sbit    reset_int       =       control1^6;
  19          sbit    reserved        =       control1^7;
  20          
  21          unsigned char   bdata   control2=0;
  22          sbit    enable_LG       =       control2^0;
  23          sbit    enable_HG       =       control2^1;
  24          sbit    count_LG0       =       control2^2;
  25          sbit    count_LG1       =       control2^3;
  26          sbit    count_HG0       =       control2^4;
  27          sbit    count_HG1       =       control2^5;
  28          sbit    any_motion      =       control2^6;
  29          sbit    alert           =       control2^7;
  30          
  31          unsigned char   bdata   control3=0;
  32          sbit    wake_up                 =       control3^0;
  33          sbit    wake_up_pause0  =       control3^1;
  34          sbit    wake_up_pause1  =       control3^2;
  35          sbit    shadow_dis              =       control3^3;
  36          sbit    latch_int               =       control3^4;
  37          sbit    new_data_int    =       control3^5;
  38          sbit    enable_adv_int  =       control3^6;
  39          sbit    SPI4                    =       control3^7;
  40          
  41          unsigned char   data    chip_ID=0;
  42          unsigned char   data    LG_thres=0;
  43          unsigned char   data    LG_dur=0;
  44          unsigned char   data    HG_thres=0;
  45          unsigned char   data    HG_dur=0;
  46          unsigned char   data    any_motion_thres=0;
  47          unsigned char   data    any_motion_dur=0;
  48          unsigned char   data    range_bandwidth=0;
  49          
  50          unsigned char   data    command;
  51          unsigned char   data    comaddr,comdata;
  52          unsigned char   data    rec_new;
  53          unsigned char   data    index;
  54          
  55          
C51 COMPILER V7.06   MAIN                                                                  04/18/2008 12:26:28 PAGE 2   

  56          /*  函数声明 */
  57          extern void                     WriteByte(unsigned char addr, unsigned char dat);
  58          extern unsigned char    ReadByte(unsigned char addr);
  59          extern unsigned char    ReadID(unsigned char addr);
  60          void                                    Delay30mS(void);
  61          void                                    SystemInit(void);
  62          void                                    SetParameter(void);
  63          
  64          void main(void)
  65          {               
  66   1              CSB=1;
  67   1              SDI=1;
  68   1              SDO=1;
  69   1              SCK=1;
  70   1              Delay30mS();    
  71   1              SystemInit();
  72   1              rec_new=0;
  73   1              index=0;
  74   1              SetParameter();
  75   1              while(1)
  76   1              {
  77   2                      if(rec_new==1)
  78   2                      {
  79   3                              rec_new=0;
  80   3                              switch(command)
  81   3                              {
  82   4                                      case 0x80:
  83   4                                                      comdata=ReadByte(comaddr+0x80);
  84   4                                                      Delay30mS();
  85   4                                                      index=0;
  86   4                                                      SBUF=command;                                           
  87   4                                                      break;
  88   4                                      case 0x00:
  89   4                                                      WriteByte(comaddr,comdata);
  90   4                                                      Delay30mS();                                            
  91   4                                                      index=0;
  92   4                                                      SBUF=command;
  93   4                                                      break;                          
  94   4                              }
  95   3                      }
  96   2              }
  97   1              
  98   1      }
  99          
 100          void                                    Delay30mS(void)
 101          {
 102   1              /*11.0592MHz晶振下~30mS*/
 103   1              register unsigned char  i,j;
 104   1              i=100;
 105   1              j=50;
 106   1              while(j--)
 107   1              {
 108   2                      while(i--);
 109   2                      i=100;
 110   2              };
 111   1      }
 112          
 113          void                                    SystemInit(void)
 114          {
 115   1              TMOD    =       0x20;
 116   1              TH1             =       0xfd;   //9600bits/s
 117   1              TL1             =       0xfd;
C51 COMPILER V7.06   MAIN                                                                  04/18/2008 12:26:28 PAGE 3   

 118   1              TCON    =       0x40;
 119   1              PCON    =       0x00;
 120   1              SCON    =       0x50;
 121   1              IE              =       0x90;
 122   1      }
 123          
 124          void                                    SetParameter(void)
 125          {
 126   1              SPI4=1;
 127   1              WriteByte(0x15,control3);
 128   1              Delay30mS();
 129   1              ee_w=1;
 130   1              WriteByte(0x0a,control1);
 131   1              Delay30mS();    
 132   1              any_motion=1;
 133   1              WriteByte(0x2b,control2);
 134   1              Delay30mS();
 135   1              any_motion_thres=0x05;
 136   1              WriteByte(0x30,any_motion_thres);
 137   1              Delay30mS();
 138   1              any_motion_dur=0x00;
 139   1              WriteByte(0x31,any_motion_dur);
 140   1              Delay30mS();
 141   1              range_bandwidth=0x02;
 142   1              WriteByte(0x34,range_bandwidth);
 143   1              Delay30mS();
 144   1              wake_up=1;
 145   1              wake_up_pause0=0;
 146   1              wake_up_pause1=0;
 147   1              enable_adv_int=1;
 148   1              SPI4=1;
 149   1              WriteByte(0x35,control3);
 150   1              Delay30mS();
 151   1              ee_w=0;
 152   1              WriteByte(0x0a,control1);
 153   1              while(1){};     
 154   1      }
 155          
 156          void                                    serialINT(void) interrupt 4
 157          {
 158   1              if(RI)
 159   1              {
 160   2                      RI=0;
 161   2                      if(index==0)
 162   2                              command=SBUF;
 163   2                      else if(index==1)
 164   2                              comaddr=SBUF;
 165   2                      else if(index==2)
 166   2                      {
 167   3                              comdata=SBUF;
 168   3                              rec_new=1;
 169   3                              index=0;
 170   3                      }
 171   2                      index++;
 172   2              }
 173   1              else if(TI)
 174   1              {
 175   2                      TI=0;
 176   2                      index++;
 177   2                      if(index==1)
 178   2                              SBUF=comaddr;
 179   2                      else if(index==2)
C51 COMPILER V7.06   MAIN                                                                  04/18/2008 12:26:28 PAGE 4   

 180   2                              SBUF=comdata;                   
 181   2                      else if(index==3)
 182   2                              index=0;
 183   2              }
 184   1      }
 185          
 186          
 187          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    312    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =     16    ----
   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 + -