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

📄 flashcode1.lst

📁 ST公司的upsd34XX评估板固定源程序
💻 LST
📖 第 1 页 / 共 3 页
字号:
C51 COMPILER V7.06   FLASHCODE1                                                            10/15/2004 20:55:30 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE FLASHCODE1
OBJECT MODULE PLACED IN Flashcode1.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE Flashcode1.c LARGE BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1           /* `=========================================================================`
   2          
   3                              ***************************************
   4                            ****   *                           *   ****
   5                                         Title: FLASHCODE1
   6                                      File name: Flashcode1.c
   7                                      Project name: FLASHCODE1
   8                            ***                                    ****
   9                              ****************** * ******************
  10                            ****                                   ****
  11                                        Author: Petr PFEIFER
  12                                     MPG Prague, Czech Republic
  13                            ****   *                           *   ****
  14                              ***************************************
  15          
  16                           $Version:  0.010   Build: 2004-01-28,12:15:55
  17          
  18           
  19           
  20                                            Description:
  21                                            ============
  22                                based on the previous DEMO 1.07 version,
  23                                        Erase problem fixed.
  24                         Since version 0.004 only one uPSD3200.h is needed.
  25          
  26          
  27                                               Notes:
  28                                               ======
  29                                               - none
  30          
  31          
  32          
  33          
  34                                     ..........................
  35                                    .                          .
  36                                    .      ******************  .
  37                                    .     **PPPPPPPPPPPPPPPP   .
  38                                    .     *PPPP*******PP****   .
  39                                    .    **PPP********PP***    .
  40                                    .    ***PPP******PP****    .
  41                                    .   *****PPP****PP****     .
  42                                    .   *****PPP****PP****     .
  43                                    .  PPPPPPPP****PP****  (R) .
  44                                    .                          .
  45                                     ..........................
  46          
  47          
  48                                            =-=-=-=-=-=
  49                                     =-=-=-=-=-=-=-=-=-=-=-=-=
  50                          =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  51          
  52                                 Copyright 2004 ST Microelectronics
  53          
  54                       This code/file is provided as is and has no warranty,
  55               implied or otherwise.  You are free to use/modify any of the provided
C51 COMPILER V7.06   FLASHCODE1                                                            10/15/2004 20:55:30 PAGE 2   

  56              code at your own risk in your applications with the expressed limitation
  57                  of liability (see below) so long as your product using the code
  58                           contains at least one uPSD products (device).
  59          
  60                                      LIMITATION OF LIABILITY:
  61                                      ========================
  62                        NEITHER STMicroelectronics NOR ITS VENDORS OR AGENTS
  63                SHALL BE LIABLE FOR ANY LOSS OF PROFITS, LOSS OF USE, LOSS OF DATA,
  64                 INTERRUPTION OF BUSINESS, NOR FOR INDIRECT, SPECIAL, INCIDENTAL OR
  65                 CONSEQUENTIAL DAMAGES OF ANY KIND WHETHER UNDER THIS AGREEMENT OR
  66                   OTHERWISE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
  67          
  68                          =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  69                                     =-=-=-=-=-=-=-=-=-=-=-=-=
  70                                            =-=-=-=-=-=
  71          
  72                             For current information on uPSD products,
  73                          please consult our pages on the World Wide Web:
  74          
  75                                           www.st.com/psm
  76          
  77                                      - - - - - - - - - - - -
  78          
  79                               STMicroelectronics GROUP OF COMPANIES
  80              Australia - Brazil - China - Czech Republic - Finland - France - Germany
  81             Hong Kong - India - Italy - Japan - Malaysia - Malta - Morocco - Singapore
  82                       Spain - Sweden - Switzerland - United Kingdom - U.S.A.
  83          
  84                                         http://www.st.com
  85          
  86          
  87           `========================================================================` */
  88          
  89          #pragma NOAREGS
  90          
  91          #include "uPSD3200.h"
  92          
  93          
  94          /* Function prototypes
  95                                                 */
  96          #define _F_W_W_P
  97          #define _F_E_B
  98          #define _F_R
  99          
 100          
 101          unsigned char flash_write_with_poll(
 102              volatile unsigned char xdata *addr, unsigned char dat);
 103          unsigned char flash_erase_sector(
 104              volatile unsigned char xdata* flash_bulk_erase_address);
 105          unsigned char flash_boot_write_with_poll(
 106              volatile unsigned char xdata *addr, unsigned char dat);
 107          unsigned char flash_boot_erase_sector(
 108              volatile unsigned char xdata* flash_boot_bulk_erase_address);
 109          
 110          unsigned char flash_write_with_toggle(unsigned char *addr,unsigned char dat);
 111          void flash_reset(void);
 112          unsigned char flash_read_id(unsigned char *flash_id_address);
 113          unsigned char flash_read_sector_protect(void);
 114          unsigned char flash_boot_write_with_toggle(volatile unsigned char *addr,
 115          unsigned char dat);
 116          void flash_boot_reset(void);
 117          unsigned char flash_boot_read_id(volatile unsigned char *flash_boot_id_address);
C51 COMPILER V7.06   FLASHCODE1                                                            10/15/2004 20:55:30 PAGE 3   

 118          unsigned char flash_boot_read_sector_protect(void);
 119          
 120          
 121          
 122          
 123          #ifdef _F_W_W_P
 124          
 125          unsigned char flash_write_with_poll(volatile uchar xdata* addr, uchar dat)
 126          /******************************************************************************
 127           Function   : unsigned char flash_write_with_poll()
 128           Parameters : (volatile uchar xdata* addr, uchar dat)
 129           Description: Writes data to flash
 130           ******************************************************************************/
 131           {
 132   1        unsigned char done;
 133   1        unsigned char error;
 134   1        unsigned char err;
 135   1        unsigned char poll;
 136   1      
 137   1        done = FALSE;
 138   1        err = FALSE;
 139   1      
 140   1                                  //  Note:  the following constants (FLASH_COMMON_XXXX)
 141   1                                    //     are declared type volatile in the header file
 142   1                                    //    so they are not optimized away by the compiler
 143   1      
 144   1      
 145   1        *(FLASH_COMMON_X555) = 0xAA;   // unlock main flash, write 0xAA to addess 0xX555
 146   1        *(FLASH_COMMON_XAAA) = 0x55;   // unlock main flash, write 0x55 to addess 0xXAAA
 147   1        *(FLASH_COMMON_X555) = 0xA0;               // write 0xA0 command to program
 148   1      
 149   1        *(addr) = dat;                             // write byte to flash
 150   1        dat = dat & NVM_DATA_POLL;                 // get bit DQ7 of original dat
 151   1      
 152   1        do                      // now use dat polling method to verify successful write
 153   1         {
 154   2          poll = *(addr);                  // Read the location that was just programmed
 155   2          error = poll & NVM_ERROR;                // save timeout error bit at DQ5
 156   2          poll = poll & NVM_DATA_POLL;           // get DQ7 of poll byte read from flash
 157   2          if (dat == poll)                         // compare DQ7
 158   2           {
 159   3            done = TRUE;                           // dat byte programmed into flash OK,
 160   3                                                   // indicate successful exit criteria
 161   3           }
 162   2          else if (error ==  NVM_ERROR )           // check for timeout error
 163   2           {
 164   3            err = TRUE;                            // indicate timeout error occurred
 165   3           }
 166   2      
 167   2         }
 168   1        while((done == FALSE) && (err == FALSE));
 169   1      
 170   1      
 171   1        if (err == TRUE)                  // make sure timeout error and dat poll didn't
 172   1                                                   // occur simultaneously
 173   1         {
 174   2          poll = *(addr);                          // Read location in flash again
 175   2          poll = poll & NVM_DATA_POLL;           // get DQ7 of poll byte read from flash
 176   2          if (dat == poll)                         // compare DQ7
 177   2           {
 178   3            done = TRUE;                // dat byte programmed into flash OK at the same
 179   3                         // time timout error occured, indicate successful exit criteria
C51 COMPILER V7.06   FLASHCODE1                                                            10/15/2004 20:55:30 PAGE 4   

 180   3           }
 181   2          *(FLASH_COMMON_X555) = 0xF0;// reset the flash array (short reset instruction)
 182   2                                                   // now delay 3 msec per dat sheet
 183   2         }
 184   1        return(done);     // a successful flash write returns 1, timeout error returns 0
 185   1       }
 186          
 187          
 188          
 189          
 190          
 191          
 192          unsigned char flash_boot_write_with_poll(volatile uchar xdata* addr, uchar dat)
 193          /******************************************************************************
 194           Function   : unsigned char flash_boot_write_with_poll()
 195           Parameters : (volatile uchar xdata* addr, uchar dat)
 196           Description: Writes data to boot flash
 197           ******************************************************************************/
 198           {
 199   1        unsigned char done;
 200   1        unsigned char error;
 201   1        unsigned char err;
 202   1        unsigned char poll;
 203   1      
 204   1        done = FALSE;
 205   1        err = FALSE;
 206   1                                    //  Note:  the following constants (FLASH_BOOT_XXXX)
 207   1                                    //     are declared type volatile in the header file
 208   1                                    //    so they are not optimized away by the compiler
 209   1      
 210   1        *(FLASH_BOOT_X555) = 0xAA;     // unlock main flash, write 0xAA to addess 0xX555
 211   1        *(FLASH_BOOT_XAAA) = 0x55;     // unlock main flash, write 0x55 to addess 0xXAAA

⌨️ 快捷键说明

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