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

📄 i2c.lst

📁 美新公司加速度芯片MXC6020,IIC接口 用C8051f320自带IIC控制器对该加速度芯片进行读写操作,并带信号处理算法
💻 LST
字号:
C51 COMPILER V7.20   I2C                                                                   05/15/2007 15:33:37 PAGE 1   


C51 COMPILER V7.20, COMPILATION OF MODULE I2C
OBJECT MODULE PLACED IN I2C.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\c51.exe I2C.c DB OE

line level    source

   1          #include "MEMSIC.h"
   2          
   3          
   4          uint8 xdata Temp0;
   5          uint8 xdata Temp1;
   6          uint8 xdata Temp2;
   7          uint8 xdata Temp3;
   8          int16 xdata Ax;
   9          int16 xdata Ay;
  10          
  11          void SMBus_Initial(void)
  12          {
  13   1          SMB0CF = 0x54;
  14   1              SMB0CF |= 0x80;
  15   1      }
  16          
  17          
  18          void Read_Acc (void)                                    //read acceleration
  19          {
  20   1              
  21   1          SMB0CF &= 0x7f;
  22   1          SMB0CF |= 0x80;
  23   1              STA = 1;//打开启动信号
  24   1              
  25   1              while(SI != 1);//等待启动中断
  26   1              if( (SMB0CN & 0xf0) == 0xe0 )
  27   1              {
  28   2                  SMB0DAT = 0x20;//地址+写
  29   2                  STA = 0;//关闭启动信号
  30   2                  SI = 0;//中断清除
  31   2              }
  32   1      
  33   1      
  34   1              while(SI != 1);//等待 地址+写 中断
  35   1              if( SMB0CN == 0xc3 )
  36   1              {
  37   2                  SMB0DAT = 0x01;//输入将访问地址
  38   2                  SI = 0;//中断清除
  39   2              }
  40   1      
  41   1      
  42   1              while(SI != 1);//等待 输入将访问地址 中断
  43   1              if( SMB0CN == 0xc3 )
  44   1              {
  45   2                  STA = 1;
  46   2                  STO = 1;//stop and then start
  47   2                  SI = 0;//clear interrupt
  48   2              }
  49   1      
  50   1      
  51   1      
  52   1      
  53   1      
  54   1      
  55   1      
C51 COMPILER V7.20   I2C                                                                   05/15/2007 15:33:37 PAGE 2   

  56   1      
  57   1          
  58   1      
  59   1              while(SI != 1);
  60   1              if( (SMB0CN & 0xf0) == 0xe0 )
  61   1              {
  62   2                  SMB0DAT = 0x21;//address + read
  63   2                  STA = 0;//clear start signal
  64   2                  SI = 0;//clear interrupt
  65   2              }
  66   1      
  67   1      
  68   1              while(SI != 1);
  69   1              if( SMB0CN == 0xc3 )
  70   1              {
  71   2                  SI = 0;// master send  convert to master receive
  72   2              }
  73   1      
  74   1      
  75   1          while(SI != 1);
  76   1              if( (SMB0CN & 0xf8) == 0x88 )
  77   1              {
  78   2                      Temp0 = SMB0DAT;//receive the AxH
  79   2                      ACK = 1;//send acknowledge
  80   2                      SI = 0;//clear interrupe
  81   2              }
  82   1      
  83   1      
  84   1          while(SI != 1);
  85   1              if( (SMB0CN & 0xf8) == 0x88 )
  86   1              {
  87   2                      Temp1 = SMB0DAT;//receive the AxL
  88   2                      ACK = 1;//send acknowledge
  89   2                      SI = 0;//clear interrupe
  90   2              }
  91   1      
  92   1      
  93   1          while(SI != 1);
  94   1              if( (SMB0CN & 0xf8) == 0x88 )
  95   1              {
  96   2                      Temp2 = SMB0DAT;//receive the AyH
  97   2                      ACK = 1;//send acknowledge
  98   2                      SI = 0;//clear interrupe
  99   2              }
 100   1              
 101   1      
 102   1          while(SI != 1);
 103   1              if( (SMB0CN & 0xf8) == 0x88 )
 104   1              {
 105   2                      Temp3 = SMB0DAT;//receive the AyL
 106   2                      ACK = 1;//send acknowledge
 107   2                      SI = 0;//clear interrupe
 108   2              }
 109   1      
 110   1      
 111   1              while(SI != 1);
 112   1              if( (SMB0CN & 0xf8) == 0x88 )
 113   1              {
 114   2                      ACK = 0;//send NACK
 115   2                      STO = 1;//send Stop signal
 116   2                      SI = 0;//clear interrupt
 117   2              }
C51 COMPILER V7.20   I2C                                                                   05/15/2007 15:33:37 PAGE 3   

 118   1      
 119   1      
 120   1              Ax=Temp0;
 121   1              Ax=Ax<<8;
 122   1              Ax+=Temp1;
 123   1              Ay=Temp2;
 124   1              Ay=Ay<<8;
 125   1              Ay+=Temp3;
 126   1      }


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