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

📄 24c02.lst

📁 这是一称的项目原文件,包括T9汉字输入,打印机,24C512,已经引用到产品上
💻 LST
字号:
C51 COMPILER V7.08   24C02                                                                 03/05/2007 16:38:06 PAGE 1   


C51 COMPILER V7.08, COMPILATION OF MODULE 24C02
OBJECT MODULE PLACED IN 24C02.OBJ
COMPILER INVOKED BY: D:\程序\keil c\C51\BIN\C51.EXE 24C02.c LARGE INCDIR(c:|keil) DEBUG OBJECTEXTEND

line level    source

   1          #include  <intrins.h>
   2          #include  <24C02.h>
   3          #include  <lcd128x64.h>
   4          #include <keyboard451.h>
   5          #include <print.h>
   6          #include <set.h>
   7          
   8          #define MAX_SAVE_NUM  255
   9          
  10          //DataBuff为读写数据输入/输出缓冲区的首址
  11          //ByteQuantity 为要读写数据的字节数量
  12          //Address 为EEPROM的片内地址
  13          //函数返回值为一个位变量,若返回1表示此次操作失效,0表示操作成功;
  14          //24C256的存储空间分为512页,每页64字节。总共32K字节//
  15          
  16          
  17          
  18          /**********************************hl******************************************/
  19          //往24c256中写数据 
  20          //Databuf中存的是写入的数据,Bytelen为每个记录含的字节数         adr为写数据的地址
  21          //写数成功返回“0”,不成功返回“1”
  22          /****************************************************************************/
  23          char cc256W(BYTE *Databuf,BYTE Bytelen,WORD adr)
  24          {
  25   1       BYTE len1=0,len2=0,len3=0,len4=0;
  26   1       BOOL repeat_f1=0,repeat_f2=0,repeat_f3=0;
  27   1       char status;
  28   1       len1=0x40-adr%0x40;
  29   1       if (len1>=Bytelen) status=c256W(Databuf,Bytelen,adr);
  30   1       else {
  31   2         
  32   2              status=c256W(Databuf,len1,adr);
  33   2                
  34   2              Delay1(1000); 
  35   2              Delay1(100);
  36   2      
  37   2             
  38   2              if ((status==0)&&((len2=Bytelen-len1)>0x40)) { len2=0x40;repeat_f1=1;}
  39   2              status=c256W(Databuf+len1,len2,adr+len1);
  40   2               
  41   2              Delay1(1000); 
  42   2              Delay1(100); 
  43   2              if((status==0)&&(repeat_f1))
  44   2              {
  45   3                if ((len3=(Bytelen-len1-len2))>0x40) {len3=0x40; repeat_f2=1;}
  46   3               
  47   3               status=c256W(Databuf+len1+len2,len3,adr+len1+len2);
  48   3              Delay1(1000);   
  49   3              Delay1(100); 
  50   3               
  51   3              if((status==0)&&(repeat_f2))
  52   3                {
  53   4                 len4=(Bytelen-len1-len2-len3); 
  54   4                 status=c256W(Databuf+len1+len2+len3,len4,adr+len1+len2+len3);
  55   4                }
C51 COMPILER V7.08   24C02                                                                 03/05/2007 16:38:06 PAGE 2   

  56   3              }
  57   2            }
  58   1      return(status);
  59   1      }
  60          /****************************************hl***********************************************/
  61          /*向24c256写数据 DataBuff为要写数据的首地址  ByteQuantity为要写数据的长度  Address为要存的地址*/
  62          /*当写数据成功返回“0”,不成功返回“1”*/
  63          /***************************************************************************************/
  64          char c256W(BYTE *DataBuff,BYTE ByteQuantity,WORD Address)
  65          {
  66   1       BYTE kk,j=0,status=1;
  67   1       ES=0;
  68   1       EA=0 ;
  69   1       ROMSCL=1;
  70   1       ROMSDA=1;
  71   1       Delay1(1);
  72   1       IICStart();//hl//启动总线
  73   1       if (!IICSendByte(0xa0))  //hl//发送Device  Address
  74   1       {
  75   2      
  76   2         if (!IICSendByte((BYTE)(Address>>8)))  //hl//发  WORD ADDRESS
  77   2         {
  78   3            if (!IICSendByte((BYTE)(Address)))
  79   3                {
  80   4          for(j=0;j<ByteQuantity;j++)
  81   4          {
  82   5           kk=*(DataBuff+j); 
  83   5           if(IICSendByte(kk)) {j=ByteQuantity;status=1;}//hl//发送数据不成功IICSendByte(kk)返回“1”
  84   5           else status=0;
  85   5              }
  86   4         IICStop();//hl//停止总线
  87   4        }
  88   3       }
  89   2      }
  90   1       
  91   1       EA=1;
  92   1       ES=1;
  93   1       return(status);  
  94   1      }
  95          
  96          /*************************************hl***************************************/
  97          //读24c256中的工作日志
  98          //Databuf中存的是读出的数据,Bytelen为每个记录含的字节数          adr为读数据的地址
  99          //读数成功返回“0”,不成功返回“1”
 100          /****************************************************************************/
 101          char cc256R(BYTE *Databuf,BYTE Bytelen,WORD adr)
 102          {
 103   1       BYTE len1=0,len2=0,len3=0,len4=0;
 104   1       BOOL repeat_f1=0,repeat_f2=0,repeat_f3=0;
 105   1       char status;
 106   1       len1=0x40-adr%0x40;//hl//要读数据的起始地址与此地址所在页页尾的差,即起始地址所在页还剩多少空间
 107   1       if (len1>=Bytelen) status=c256R(Databuf,Bytelen,adr);
 108   1                                //hl//如果起始地址不是一页的开头,并且所要读的数据都在这一页中
 109   1       else {
 110   2              status=c256R(Databuf,len1,adr);    //hl//如果要读的数据不是全部在起始地址所在的页中,只读这一页的

⌨️ 快捷键说明

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