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

📄 eeprom.lst

📁 一个调整ADC gain offset 的程序
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V7.50   EEPROM                                                                01/17/2007 12:46:56 PAGE 1   


C51 COMPILER V7.50, COMPILATION OF MODULE EEPROM
OBJECT MODULE PLACED IN .\output\eeprom.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE ..\code\eeprom.c LARGE BROWSE DEBUG OBJECTEXTEND PRINT(.\eeprom.lst) OBJECT
                    -(.\output\eeprom.obj)

line level    source

   1          #include "extData.h"
   2          #include "eeprom.h"
   3          #include "dvIIC.h"
   4          #include "utility.h"
   5          #include "Define.h"
   6          #include "dvGxCtrl.h"
   7          #include "stdio.h"
   8          #include"utility.h"
   9          /*
  10          WORD  EEPROM_Addr_2IN1[6];
  11          WORD  EEPROM_Addr_AFE[6];
  12          BYTE  EEPROM_Page_Len;
  13          BYTE  GXEEPROM_SLAVE_ADDRESS;
  14          BYTE RefGainSetting[6];
  15          BYTE RefOffsetSetting[6];
  16          */
  17          WORD RefGainSetting [6] = {0x00cf,0x00cd,0x00d0,0x0106,0x0121,0x0154};
  18          //BYTE H_RefGainSetting [6] = {0x00,0x00,0x00,0x01,0x01,0x01};
  19          WORD RefOffsetSetting [6] = {0x00df,0x00de,0x00e3,0x013d,0x011c,0x0141};
  20          //BYTE H_RefOffsetSetting [6] = {0x00,0x00,0x00,0x01,0x01,0x01};
  21          BYTE EEPROM_Page_Len = 0x10;
  22          BYTE GXEEPROM_SLAVE_ADDRESS = 0xa0;
  23          WORD EEPROM_Addr_2IN1 [6] ={0x00be,0x00c0,0x00c2,0x00c3,0x00c5,0x00c7};
  24          WORD EEPROM_Addr_AFE [6] =  {0x00d6,0x00d8,0x00da,0x00db,0x00dd,0x00df};
  25          //#define NV_PAGE_WRITE_LEN    32
  26          #define SLAVE_ADDRESS_EEPROM 0xA0
  27          
  28          void ShortDelay(WORD wDelay)
  29          {
  30   1         while(wDelay --)
  31   1        {
  32   2          ;
  33   2        }
  34   1      }
  35           void E2promDataSet(BYTE cSlaveAdr,BYTE cPageLen,WORD wRegisterAddress,WORD wLength,PBYTE pData,BOOL bFlag
             -)
  36          {
  37   1          WORD                wCurrentAddress,wEnd,i;
  38   1          WORD        wStartPage, wEndPage, wMidPages;
  39   1          WORD        wPagePremainder, wPageRemainder;
  40   1           
  41   1          wCurrentAddress = wRegisterAddress;
  42   1          wEnd = wRegisterAddress + wLength - 1;         // end address of this transfer in
  43   1                                                         // NVRAM
  44   1          wStartPage = wRegisterAddress / cPageLen;    // starting block number for
  45   1                                                      // transfer
  46   1          wEndPage = wEnd / cPageLen;    // ending block number for
  47   1      
  48   1          // If this operation is entirely within one NVRAM page, then setup for
  49   1          // that situation.
  50   1          if (wStartPage == wEndPage)
  51   1          {
  52   2              wPagePremainder = wLength;       // this transfer is handled entirely as 
  53   2                                             // premainder
C51 COMPILER V7.50   EEPROM                                                                01/17/2007 12:46:56 PAGE 2   

  54   2              wMidPages = 0;                 // no chunks in the middle
  55   2              wPageRemainder = 0;            // no remainder bytes
  56   2          }
  57   1          else
  58   1          {
  59   2              // We're not entirely within one page
  60   2              // Calculate the address of the next page boundary.
  61   2               
  62   2              // Premainder is the number of bytes before the first page boundary
  63   2              wPagePremainder = ((wRegisterAddress / cPageLen) + 1) * cPageLen - wRegisterAddress;
  64   2      
  65   2              // Check if any bytes follow the last page boundary in the transfer
  66   2              if ((wEnd + 1) % cPageLen)
  67   2              {
  68   3                  // Remainder is the number of bytes after the last page boundary
  69   3                  wPageRemainder = wEnd - (((BYTE)(wEnd /cPageLen)) *
  70   3                                           cPageLen) + 1;
  71   3              }
  72   2              else
  73   2              {
  74   3                  // Tranfer ends at a page boundary so no remainder
  75   3                  wPageRemainder = 0;
  76   3              }
  77   2          }
  78   1      
  79   1          // Calculate number of whole pages are in the middle of this transfer
  80   1             wMidPages = (wLength - wPagePremainder - wPageRemainder) /
  81   1             cPageLen;
  82   1      
  83   1          // -----------------------------------------------------------------------
  84   1          // BEGIN ACCESSING THE NVRAM
  85   1          // -----------------------------------------------------------------------
  86   1      
  87   1          // Write out the Premainder
  88   1          if (wPagePremainder)
  89   1          {
  90   2                    IICWrite(cSlaveAdr,
  91   2                                 wCurrentAddress,
  92   2                                 pData,
  93   2                                 wPagePremainder,
  94   2                                 bFlag);
  95   2                                             
  96   2                 
  97   2                  
  98   2              wCurrentAddress += wPagePremainder;
  99   2              pData +=  wPagePremainder;
 100   2              ShortDelay(500);
 101   2          }
 102   1      
 103   1          // Write out the Mid Pages
 104   1          for (i = 0; i < wMidPages; i++)
 105   1          {
 106   2               
 107   2                    IICWrite(cSlaveAdr,
 108   2                              wCurrentAddress,
 109   2                               pData,
 110   2                               cPageLen,
 111   2                               bFlag);
 112   2                                   
 113   2      
 114   2              wCurrentAddress += cPageLen;
 115   2              pData += cPageLen;
C51 COMPILER V7.50   EEPROM                                                                01/17/2007 12:46:56 PAGE 3   

 116   2              ShortDelay(500);
 117   2          }
 118   1      
 119   1          // Write out the Remainder
 120   1          if (wPageRemainder)
 121   1          {
 122   2      
 123   2                    IICWrite(cSlaveAdr,
 124   2                              wCurrentAddress,
 125   2                               pData,
 126   2                               wPageRemainder,
 127   2                               bFlag);
 128   2                                   
 129   2                   ShortDelay(500);
 130   2          }
 131   1           
 132   1               
 133   1      }
 134          
 135           BOOL E2promDataGet(BYTE cSlaveAdr,WORD wRegisterAddress,BYTE cLength,PBYTE pData,BOOL bFlag)
 136          {
 137   1        BOOL bReturn;
 138   1          bReturn=IICRead(cSlaveAdr,wRegisterAddress,pData,cLength,bFlag);
 139   1          return bReturn;
 140   1      }
 141          
 142          void EEPROMUocSettingGet(BYTE cChannel)
 143          {
 144   1      #ifdef Debug
 145   1         BYTE i;
 146   1         BYTE cGainValue;
 147   1         WORD wOffsetValue;
 148   1         BYTE bReturn;     
 149   1        
 150   1         if(cChannel==0)
 151   1        {
 152   2              for(i=0;i<3;i++)
 153   2                      {
 154   3                    bReturn=E2promDataGet(GXEEPROM_SLAVE_ADDRESS,EEPROM_Addr_2IN1[i],1,&cGainValue,0);
 155   3                  
 156   3                    TimeDelay(15);
 157   3                      printf("GainSetting_480i[%bd]= %bx,bReturn =%bd\n,",i,cGainValue,bReturn);
 158   3                      
 159   3                      }
 160   2                 for(i=0;i<3;i++)   
 161   2                      {          

⌨️ 快捷键说明

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