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

📄 cs5550.lst

📁 电子称重的程序
💻 LST
字号:
C51 COMPILER V8.02   CS5550                                                                05/04/2008 21:35:46 PAGE 1   


C51 COMPILER V8.02, COMPILATION OF MODULE CS5550
OBJECT MODULE PLACED IN CS5550.OBJ
COMPILER INVOKED BY: e:\Keil\C51\BIN\C51.EXE CS5550.C BROWSE DEBUG OBJECTEXTEND

line level    source

   1          #include        <config.h>
   2          #include        <head.h>
   3          #include        <CS5550.h>
   4          #include        <function.h>
   5          #include        <message.h>
   6          
   7          union
   8          {
   9                  long            rlong;
  10                  struct{
  11                                  unsigned char hbyte;     // High byte
  12                                  unsigned char mbyte;     // Middle byte
  13                                  unsigned char lbyte;     // Low byte
  14                                  unsigned char zbyte;     // Zero byte
  15                          }bytes;
  16          } AD_NOW;
  17          union
  18          {
  19                  Uint            rint;
  20                  struct{
  21                          unsigned char hbyte;     // High byte
  22                          unsigned char lbyte;     // Low byte
  23                          }bytes;
  24          } AD_NOW_V;
  25          BOOL    hadad;
  26          extern Uchar adchipdog;
  27          extern bit   resetadbit;
  28          BOOL    getad()
  29          {
  30   1              return  hadad;
  31   1      }
  32          long            readad()
  33          {
  34   1              hadad=0;
  35   1              return  AD_NOW.rlong;
  36   1      }
  37          Uint            readvolt()
  38          {
  39   1              return  AD_NOW_V.rint;
  40   1      }
  41          void            inin5550(char gain,char Offset)
  42          {
  43   1              reset=LOW;
  44   1              delayms(1);
  45   1              reset=HIGH;
  46   1              sdo=HIGH;
  47   1              sdi=LOW;
  48   1              sclk=LOW;
  49   1              cs_writebyte_4(Sync1,Sync1,Sync1,Sync0);
  50   1              cs_writebyte_4(WReg_Config,0x01,0x00,0x01);                 //falling //使cpu时钟反转,打开高通滤波器
  51   1              cs_writebyte_4(WReg_CycleCount,0x00,0x01,0x90);     //0190        //400       04b0 //1200 //转换速率
  52   1              cs_writebyte_4(WReg_Mask,0x80,0x00,0x00);   //允许DRDY中断
  53   1              cs_writebyte_4(WRegA1_DcOffset,Offset,0,0);
  54   1              cs_writebyte_4(WRegA1_DcGain,gain,0,0);
  55   1              cs_writebyte_4(WRegA2_DcOffset,0x00,0x00,0x00);
C51 COMPILER V8.02   CS5550                                                                05/04/2008 21:35:46 PAGE 2   

  56   1              cs_writebyte(ContnuConvs);
  57   1               //PX0=1;
  58   1              IT0=1;
  59   1              EX0=1;
  60   1              EA=1;
  61   1              adchipdog=0;
  62   1              resetadbit=0;
  63   1              while(!getad());
  64   1              //adchipdog=0;
  65   1      }
  66          //***********************************************************************
  67          
  68          BOOL    cs_clock(void)
  69          {
  70   1              BOOL    sample;
  71   1              sclk=HIGH;
  72   1              // _nop_();
  73   1              sample=sdo;
  74   1              sclk=LOW;
  75   1              // _nop_();
  76   1              return(sample);
  77   1      }
  78          
  79          //*********************************************
  80          void cs_writebyte(Uchar cs_data)
  81          {
  82   1              Uchar i;
  83   1              sclk=LOW;
  84   1              /*发送8位数据*/
  85   1              for(i=0;i<8;i++)
  86   1              {
  87   2                      sdi=(bit)(cs_data&0x80);
  88   2                      cs_data=cs_data<<1;
  89   2                      cs_clock();
  90   2              }
  91   1              /*请求应答信号ACK*/
  92   1              sdi=HIGH;
  93   1      }
  94          
  95          
  96          //*****************************************************************************
  97          void cs_writebyte_4(Uchar a,Uchar b,Uchar c,Uchar d)
  98          {
  99   1              cs_writebyte(a);
 100   1              cs_writebyte(b);
 101   1              cs_writebyte(c);
 102   1              cs_writebyte(d);
 103   1      }
 104          
 105          //*****************************************************************************
 106          void int_0(void) interrupt 0
 107          {
 108   1              adchipdog=0;
 109   1              cs_writebyte(RRegA2_FILT);
 110   1              AD_NOW_V.bytes.hbyte=int_cs_readbyte();
 111   1              AD_NOW_V.bytes.lbyte=int_cs_readbyte();
 112   1              AD_NOW_V.rint+=2354;
 113   1              AD_NOW_V.rint/=25.98;
 114   1              cs_writebyte(WReg_Status);
 115   1              cs_writebyte(0xff);
 116   1              cs_writebyte(0xff);
 117   1              cs_writebyte(0xff);
C51 COMPILER V8.02   CS5550                                                                05/04/2008 21:35:46 PAGE 3   

 118   1      
 119   1              cs_writebyte(RRegA1_Output);                  //判断符号
 120   1              if(int_cs_readbyte()&0x80)AD_NOW.rlong=0;
 121   1              else{
 122   2                      cs_writebyte(RRegA1_FILT);                  //读AD值
 123   2                      AD_NOW.bytes.mbyte=int_cs_readbyte();
 124   2                      AD_NOW.bytes.lbyte=int_cs_readbyte();
 125   2                      AD_NOW.bytes.zbyte=int_cs_readbyte();
 126   2              }
 127   1              hadad=1;
 128   1              PostMessageOne(M_ADHAD,0);
 129   1              cs_writebyte(WReg_Status);
 130   1              cs_writebyte(0xff);
 131   1              cs_writebyte(0xff);
 132   1              cs_writebyte(0xff);
 133   1      }
 134          
 135          
 136          //************************************************
 137          Uchar int_cs_readbyte(void)
 138          {
 139   1              Uchar cs_data=0;
 140   1              Uchar i;
 141   1              sdi=HIGH;
 142   1              for(i=0;i<8;i++)
 143   1              {
 144   2                      if(i==7){sdi=LOW;}
 145   2                      cs_data<<=1;
 146   2                      if(cs_clock())
 147   2                      cs_data++;
 148   2              }
 149   1              return(cs_data);
 150   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    426    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      6       6
   IDATA SIZE       =   ----    ----
   BIT SIZE         =      1       1
END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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