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

📄 rx2flash.lst

📁 mifarea卡程序mifarea卡程序mifarea卡程序
💻 LST
字号:
C51 COMPILER V8.00   RX2FLASH                                                              04/23/2009 15:56:17 PAGE 1   


C51 COMPILER V8.00, COMPILATION OF MODULE RX2FLASH
OBJECT MODULE PLACED IN .\out_sst89e564\rx2flash.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE source\rx2flash.c LARGE BROWSE ORDER NOAREGS DEBUG OBJECTEXTEND PRINT(.\rx2
                    -flash.lst) OBJECT(.\out_sst89e564\rx2flash.obj)

line level    source

   1          /* rx2flash.c */
   2          
   3          //#include<reg51rd2.h>
   4          #include"types.h"
   5          #include"c51rx2.h"
   6          #include"reg52.h"
   7          #include"stimer.h"
   8          
   9          #ifdef WATCHDOG
              //#define CLRWDT
              #endif
  12          
  13          #define _pusha()  ;
  14          #define _popa()   ;
  15          
  16          #ifndef     _pusha
              void _pusha(void);
              void _popa(void);
              #endif
  20          
  21          /********************************************
  22          * FlashFlex51 MCU SFR Memory Addresses
  23          *********************************************/
  24          sfr SFCF = 0xB1; /*SuperFlash Configuration*/
  25          sfr SFCM = 0xB2; /*SuperFlash Command*/
  26          sfr SFAL = 0xB3; /*SuperFlash Address Low*/
  27          sfr SFAH = 0xB4; /*SuperFlash Address High*/
  28          sfr SFDT = 0xB5; /*SuperFlash Data*/
  29          sfr SFST = 0xB6; /*SuperFlash Status*/
  30          /********************************************
  31          * FlashFlex51 MCU IAP Commands
  32          *********************************************/
  33          #define SFCM_SE 0x0B; /*Sector-Erase IAP cmd*/
  34          #define SFCM_VB 0x0C; /*Byte-Verify IAP cmd*/
  35          #define SFCM_PB 0x0E; /*Byte-Program IAP cmd*/
  36          /********************************************
  37          * Global Variable Definition
  38          *********************************************/
  39          const unsigned short int BLK1_DST_ADDR = 0x1000;
  40          /*SST89x564RD destination address (in the other on-chip flash memory block)
  41          where data will be written to, which is above BSL code space.*/
  42          
  43          const unsigned char SECT_SIZE = 0x80; /*number of bytes in a sector*/
  44          
  45          // test if operation is ready
  46          bool ready()
  47          {
  48   1          unsigned long int TimeOut = 0;
  49   1          
  50   1          while (TimeOut < 100000)
  51   1          {
  52   2              if ((SFST&4) == 0)      /* Check if IAP is done */
  53   2              {                       /* IAP is done */
  54   3                  SFCF = SFCF & 0xBF; /* turn off IAP*/
C51 COMPILER V8.00   RX2FLASH                                                              04/23/2009 15:56:17 PAGE 2   

  55   3                  SFDT = 0;           /* any value other than 0x55 */
  56   3                  return true;           /* IAP operation is completed*/
  57   3              }
  58   2              GetTickCount();
  59   2          }
  60   1          SFCF = SFCF & 0xBF;         /*turn off IAP*/
  61   1          SFDT = 0;                   /*any value other than 0x55*/
  62   1          return false;               /*IAP operation is NOT completed before time out*/
  63   1      }
  64          
  65          // write a byte to flash
  66          bool FlashWrByte(uint addr, uchar ch)
  67          {
  68   1          disable();
  69   1          SFCF = SFCF | 0x40;     /*enable IAP */
  70   1          SFAH = addr>>8;         /*load high order address byte*/
  71   1          SFAL = addr & 0xff;     /*load low order address byte */
  72   1          SFDT = ch;              /*load data to be programmed */
  73   1          SFCM = SFCM_PB;         /*issue byte program command */
  74   1      
  75   1          if(!ready())
  76   1          {
  77   2              enable();
  78   2              return false;
  79   2          }
  80   1              
  81   1          enable();
  82   1          return true;
  83   1      }
  84          
  85          // erase sector
  86          // addr: 00h, 80h
  87          bool FlashErSector(uint addr)
  88          {
  89   1          disable();
  90   1          SFCF = SFCF | 0x40;     /*enable IAP */
  91   1          SFAH = addr>>8;         /*load high order address byte*/
  92   1          SFAL = addr & 0xff;     /*load low order address byte */
  93   1          SFCM = SFCM_SE;         /*issue sector erase command */
  94   1      
  95   1          if(!ready())
  96   1          {
  97   2              enable();
  98   2              return false;
  99   2          }
 100   1      
 101   1          enable();
 102   1          return true;
 103   1      }
 104          
 105          // read device data
 106          uchar FlashRdByte(uint addr)
 107          {
 108   1          unsigned char readByte;
 109   1          disable();
 110   1          SFCF = SFCF | 0x40;     /*enable IAP */
 111   1          SFAH = addr>>8;         /*load high order address byte*/
 112   1          SFAL = addr & 0xff;     /*load low order address byte */
 113   1          SFCM = SFCM_VB;         /*issue byte verify command */
 114   1          readByte = SFDT;
 115   1          SFCF = SFCF & 0xBF;     /*turn off IAP*/
 116   1          SFDT = 0;
C51 COMPILER V8.00   RX2FLASH                                                              04/23/2009 15:56:17 PAGE 3   

 117   1          enable();
 118   1          return readByte;
 119   1      }
 120          
 121          #if 0
              void ErBlock0(void)
              {
                  SFCF = SFCF | 0x40;
                  SFAH = 
                  SFAL = 
                  SFDT = 0x55;
                  SFCM = 0x0d;
              }
              #endif


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    163    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =      3       4
   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 + -