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

📄 1.lst

📁 SST25VF016B是一款外部flash芯片
💻 LST
字号:
C51 COMPILER V8.02   1                                                                     02/26/2009 21:33:17 PAGE 1   


C51 COMPILER V8.02, COMPILATION OF MODULE 1
OBJECT MODULE PLACED IN 1.OBJ
COMPILER INVOKED BY: E:\应用软件\Keil\C51\BIN\C51.EXE 1.c BROWSE DEBUG OBJECTEXTEND

line level    source

   1          #include<reg52.h>
   2          #include <intrins.h>
   3          
   4          #define uchar unsigned char
   5          #define uint unsigned int
   6          #define ulong   unsigned long    
   7           ///////////引脚定义
   8          sbit  SCLK =P2^7;
   9          sbit  MISO =P2^6;
  10          sbit  MISI =P2^5;
  11          sbit  CS   =P2^4;
  12                          
  13          sbit  lcden=P0^2; 
  14          sbit  lcdrs=P0^0;
  15          sbit  rw=P0^1;
  16          
  17          
  18          uchar dat[10]={1,2,3,4,5,6,7,8,9,1};
  19          uchar add[3]={1,0,1};
  20          uchar R_dat[10];
  21          uchar code table0[]="成都信息工程学院";
  22          uint num;
  23          
  24          void Flash_init()  ;    /* 程序功能:    用来将时钟线初始化为低. 必须在将设备设置为模式0之前调用*/
  25          void Flash_WRSR(uchar byte)  ;//写状态寄存器
  26          uchar Flash_Read_Status_Register(void);   //读状态寄存器的值
  27          void Flash_WREN_Check(void)  ;          /* 功能: 检查擦写操作前WEL位是否为1  */   
  28          void  Flash_WREN(void) ;         //写使能命令
  29          void Flash_Sector_Erase(ulong Dst) ;  /* 功能: Sector Erases the Chip.     4K         */
  30          void Flash_Wait_Busy(void)  ;//等待 FLASH空闲
  31          void Flash_Chip_Erase(void)   ;         /* 功能: 擦除整个芯片               */  
  32          void Flash_Block_Erase_32K(ulong Dst) ;  /* 功能: Block Erases 32 KByte of the Chip.           */
  33          void Flash_Block_Erase_64K(ulong Dst) ;
  34          void Flash_EWSR(void) ; //;使能改写状态寄存器 
  35          void   Flash_WRDI(void)   ;//   禁止写使能
  36          
  37          void Flash_Send_Byte(uchar dat) ;//发送一个数据char 型 的  从51到FLASH
  38          uchar  Flash_Get_Byte(void);// 接收一个char型的数据         51接收
  39          uchar  Flash_Read(ulong Dst);//读取一个措定地址内的一个数据  作为函数返回值
  40          void Flash_Write(ulong Dst,uchar dat);  //向flash 内的一个地址内写入一个数据
  41          
  42          void Flash_Write_data(uchar  add[],uchar dat[],uchar size);     //向flash 内的一个基地址 add[3],add[0]放地址高
             -八位         内写入size个数据。
  43          
  44           //向从flash 内的一个基地址 add[3],add[0]放地址高八位         内读出size个数据。           放到dat[]中
  45          void Flash_Read_data(uchar  add[],uchar R_dat[],uchar size);
  46          
  47          //向从flash 内的一个基地址 add,      内读出size个数据。    放到dat[]中
  48          void Flash_Read_data_add(ulong Dst,uchar R_dat[],uchar size);
  49          void Flash_Write_data_add(ulong Dst,uchar dat[],uchar size);//向flash 内的一个基地址 add    
  50          
  51          
  52          delay(uint z)
  53          {
  54   1              uint x,y;
C51 COMPILER V8.02   1                                                                     02/26/2009 21:33:17 PAGE 2   

  55   1              for(x=z;x>0;x--)
  56   1                      for(y=110;y>0;y--);
  57   1      } 
  58          void write_com(uchar com)
  59          {
  60   1              lcdrs=0;
  61   1              P1=com;
  62   1              delay(5);
  63   1              lcden=1;
  64   1              delay(5);
  65   1              lcden=0;
  66   1      }
  67          
  68          void write_data(uchar date)      
  69          {
  70   1              lcdrs=1;
  71   1              P1=date;
  72   1              delay(5);
  73   1              lcden=1;
  74   1              delay(5);
  75   1              lcden=0;
  76   1      }
  77          void init()
  78          {
  79   1              lcden=0;
  80   1              rw=0;
  81   1              write_com(0x38);
  82   1              write_com(0x0c);
  83   1              write_com(0x06);
  84   1              write_com(0x80);
  85   1      }
  86          /*------------------显示字符串--------------------------*/
  87          void write(unsigned char  *s)
  88          { while(*s>0)
  89   1         {
  90   2          write_data(*s);
  91   2            s++;
  92   2            delay(30);
  93   2         }
  94   1      }
  95          
  96          
  97          
  98          
  99          ////////////////////////////////////SPI读写驱动///////////////////////////////////////////////////////////
             -/////////////////////
 100          void Flash_Send_Byte(uchar dat) //发送一个数据char 型 的  从51到FLASH
 101          {
 102   1      uchar i;
 103   1      SCLK=0;
 104   1      CS=0;
 105   1      for(i=0;i<8;i++)
 106   1          { 
 107   2            if(dat & 0x80)
 108   2               {
 109   3                   MISI=1;
 110   3               }
 111   2            else 
 112   2                   MISI=0;
 113   2              dat<<=1;
 114   2              SCLK=1;    //信号拉高读进数据
 115   2              _nop_();
C51 COMPILER V8.02   1                                                                     02/26/2009 21:33:17 PAGE 3   

 116   2              
 117   2                  SCLK=0;    //将信号拉低
 118   2              _nop_();     
 119   2            }
 120   1      SCLK=0;
 121   1      }
 122          
 123          uchar Flash_Get_Byte(void)   //接收一个char型的数据
 124          {
 125   1      uchar i;
 126   1      uchar one_data=0;
 127   1      CS=0;
 128   1      // SCLK=1;
 129   1      for(i=0;i<8;i++)
 130   1      {        
 131   2              one_data=one_data<<1;
 132   2              SCLK=0;
 133   2              _nop_();
 134   2                 _nop_();
 135   2               if(MISO==1)
 136   2               {
 137   3               one_data=one_data | 0x01;
 138   3               }
 139   2          SCLK=1;
 140   2          _nop_();    
 141   2      }
 142   1      SCLK=0;
 143   1      //CS=1;
 144   1      return one_data;
 145   1      }
 146          
 147          /************************************************************************/   
 148                  /* 名称: Read                         */     
 149                  /* 功能: 读取一个地址内一个字节的数据.返回读取的数据*/   
 150                  /* 输入:      Dst:    Destination Address 000000H - 1FFFFFH       */   
 151                  /* 返回:      byte                            */   
 152                  /************************************************************************/   
 153          uchar Flash_Read(ulong Dst)    
 154                  {   
 155   1                  uchar byte = 0; 
 156   1                      
 157   1                      SCLK=1;   
 158   1                  CS =0;  
 159   1                              /* enable device */   
 160   1                  Flash_Send_Byte(0x03);        /* read command */   
 161   1                  Flash_Send_Byte(((Dst & 0xFFFFFF) >> 16));  /* send 3 address bytes */   
 162   1                  Flash_Send_Byte(((Dst & 0xFFFF) >> 8));   
 163   1                  Flash_Send_Byte(Dst & 0xFF);   
 164   1                  byte = Flash_Get_Byte();   
 165   1                  CS =1;          /* disable device */   
 166   1                  return byte;            /* return one byte read */   
 167   1              }   
 168          ////////////////////////////////////////////////////////////////////////////////////////////////
 169          void Flash_Write(ulong Dst,uchar dat)   //向flash 内的一个地址内写入一个数据。
 170          {
 171   1      CS=0;
 172   1              Flash_Send_Byte(0x02);        /* read command */   
 173   1                  Flash_Send_Byte(((Dst & 0xFFFFFF) >> 16));  /* send 3 address bytes */   
 174   1                  Flash_Send_Byte(((Dst & 0xFFFF) >> 8));   
 175   1                  Flash_Send_Byte(Dst & 0xFF); 
 176   1              Flash_Send_Byte(dat);///secd data to flash
 177   1      CS=1;
C51 COMPILER V8.02   1                                                                     02/26/2009 21:33:17 PAGE 4   

 178   1      
 179   1      }
 180          
 181          void Flash_Write_data(uchar  add[],uchar dat[],uchar size)      //向flash 内的一个基地址 add[3],add[0]放地址高

⌨️ 快捷键说明

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