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

📄 f330_flashp.lst

📁 f330与mfrc522 通信 构成读卡器 上传源码和原理图。
💻 LST
字号:
C51 COMPILER V6.23a  F330_FLASHP                                                           04/14/2008 15:21:35 PAGE 1   


C51 COMPILER V6.23a, COMPILATION OF MODULE F330_FLASHP
OBJECT MODULE PLACED IN F330_FlashP.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\c51.exe F330_FlashP.c DB OE

stmt level    source

   1          //-----------------------------------------------------------------------------
   2          // F330_FlashPrimitives.c
   3          //-----------------------------------------------------------------------------
   4          // Copyright 2004 Silicon Laboratories, Inc.
   5          // This program contains several useful utilities for writing and updating
   6          // FLASH memory.
   7          // AUTH: BW & GP
   8          // DATE: 21 JUL 04
   9          // Target: C8051F33x
  10          // Tool chain: KEIL C51 7.06
  11          //-----------------------------------------------------------------------------
  12          // Includes
  13          //-----------------------------------------------------------------------------
  14          #include "F330_FlashP.h"
  15          #include <c8051F330.h>
  16          //-----------------------------------------------------------------------------
  17          // Structures, Unions, Enumerations, and Type Definitions
  18          //-----------------------------------------------------------------------------
  19          
  20          //-----------------------------------------------------------------------------
  21          // Global Constants
  22          //-----------------------------------------------------------------------------
  23          
  24          //-----------------------------------------------------------------------------
  25          // Function Prototypes
  26          //-----------------------------------------------------------------------------
  27          
  28          //-----------------------------------------------------------------------------
  29          // Global Variables
  30          //-----------------------------------------------------------------------------
  31          
  32          //************************************************************
  33          // FLASH Routines
  34          //************************************************************
  35          // FLASH_Read:This routine copies <numbytes> from 
  36          //the linear FLASH address <src> to <dest>.
  37          //************************************************************
  38          char * FLASH_Read (char *dest, FLADDR src, UCHAR numbytes)
  39          {
  40   1         FLADDR i;
  41   1      
  42   1         for (i = 0; i < numbytes; i++) 
  43   1         {
  44   2            *dest++ = FLASH_ByteRead (src+i);
  45   2         }
  46   1         return dest;
  47   1      }
  48          //************************************************************
  49          // FLASH_ByteRead:
  50          //This routine reads a <byte> from the linear FLASH address <addr>.
  51          //************************************************************
  52          UCHAR FLASH_ByteRead (FLADDR addr)
  53          {           
  54   1         char code * data pread;     // FLASH read pointer
  55   1         UCHAR byte;
C51 COMPILER V6.23a  F330_FLASHP                                                           04/14/2008 15:21:35 PAGE 2   

  56   1      
  57   1         pread = (char code *)addr;
  58   1         byte = *pread;             // read the byte
  59   1         return byte;
  60   1      }
  61          //************************************************************
  62          // FLASH_Write:This routine copies <numbytes> from <src> to
  63          //************************************************************
  64          void FLASH_Write (FLADDR dest, UCHAR *src, UCHAR numbytes)
  65          {
  66   1         char xdata * data pwrite;  // FLASH write pointer
  67   1         UCHAR i;
  68   1         bit   EA_SAVE;
  69   1      
  70   1         pwrite = (char xdata *)dest;
  71   1      
  72   1         EA_SAVE = EA;          // preserve EA
  73   1         EA = 0;                // disable interrupts
  74   1      
  75   1         pwrite = (char xdata *) dest;
  76   1      
  77   1         PSCTL |= 0x01;         // PSWE = 1
  78   1      
  79   1         for (i =0; i < numbytes; i++) 
  80   1           {
  81   2              FLKEY  = 0xA5;                 // Key Sequence 1
  82   2              FLKEY  = 0xF1;                 // Key Sequence 2
  83   2              *pwrite =*src++;
  84   2              pwrite++;
  85   2            }
  86   1         PSCTL &= ~0x01;                // PSWE = 0
  87   1         EA = EA_SAVE;                  // restore interrupts
  88   1      }
  89          
  90          //************************************************************
  91          // FLASH_ByteWrite:This routine writes <byte> to the linear FLASH address <addr>.
  92          //To do:optimize to skip 0xFF bytes
  93          //************************************************************
  94          void FLASH_ByteWrite (FLADDR addr, UCHAR byte)
  95          {
  96   1         bit EA_SAVE = EA;          // preserve EA
  97   1         char xdata * data pwrite;  // FLASH write pointer
  98   1      
  99   1         EA = 0;                    // disable interrupts
 100   1         // change clock speed to slow, then restore later
 101   1         VDM0CN = 0x80;                 // enable VDD monitor
 102   1         RSTSRC = 0x02;                 // enable VDD monitor as a reset source
 103   1         pwrite = (char xdata *) addr;
 104   1      
 105   1         PSCTL |= 0x01;                 // PSWE = 1
 106   1         FLKEY  = 0xA5;                 // Key Sequence 1
 107   1         FLKEY  = 0xF1;                 // Key Sequence 2
 108   1         
 109   1      //   VDM0CN = 0x80;               // enable VDD monitor
 110   1      //   RSTSRC = 0x02;               // enable VDD monitor as a reset source
 111   1         *pwrite = byte;                // write the byte
 112   1         PSCTL &= ~0x01;                // PSWE = 0
 113   1         EA = EA_SAVE;                  // restore interrupts
 114   1      }
 115          //************************************************************
 116          // FLASH_PageErase:This routine erases the FLASH page containing 
 117          //the linear FLASH address <addr>
C51 COMPILER V6.23a  F330_FLASHP                                                           04/14/2008 15:21:35 PAGE 3   

 118          //************************************************************
 119          void FLASH_PageErase (FLADDR addr)
 120          {  
 121   1         char xdata * data pwrite;     // FLASH write pointer
 122   1         bit EA_SAVE = EA;             // preserve EA
 123   1      
 124   1         EA = 0;                       // disable interrupts
 125   1         // change clock speed to slow, then restore later
 126   1         pwrite = (char xdata *) addr;
 127   1      
 128   1         PSCTL |= 0x03;                // PSWE = 1; PSEE = 1
 129   1         FLKEY  = 0xA5;                // Key Sequence 1
 130   1         FLKEY  = 0xF1;                // Key Sequence 2
 131   1      
 132   1         *pwrite = 0;                  // initiate page erase
 133   1      
 134   1         PSCTL &= ~0x03;               // PSWE = 0; PSEE = 0
 135   1      
 136   1         EA = EA_SAVE;                 // restore interrupts
 137   1      }
 138          //************************************************************


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    221    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----      14
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----       3
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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