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

📄 flashcode1.lst

📁 upsd 3200序列的usb驱动
💻 LST
📖 第 1 页 / 共 3 页
字号:
C51 COMPILER V7.00 Beta 6  FLASHCODE1                                                      02/19/2003 15:59:28 PAGE 1   


C51 COMPILER V7.00 Beta 6, 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          psd834f2.c
   4          
   5          */
   6          
   7          /*---------------------------------------------------------------------------
   8          Copyright (c) 2002 ST Microelectronics
   9          This example demo code is provided as is and has no warranty,
  10          implied or otherwise.  You are free to use/modify any of the provided
  11          code at your own risk in your applications with the expressed limitation
  12          of liability (see below) so long as your product using the code contains
  13          at least one uPSD products (device).
  14          
  15          LIMITATION OF LIABILITY:   NEITHER STMicroelectronics NOR ITS VENDORS OR 
  16          AGENTS SHALL BE LIABLE FOR ANY LOSS OF PROFITS, LOSS OF USE, LOSS OF DATA,
  17          INTERRUPTION OF BUSINESS, NOR FOR INDIRECT, SPECIAL, INCIDENTAL OR
  18          CONSEQUENTIAL DAMAGES OF ANY KIND WHETHER UNDER THIS AGREEMENT OR
  19          OTHERWISE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
  20          --------------------------------------------------------------------------*/
  21          
  22          /*
  23          These functions are provided to help you develop your initial code. 
  24          They are optimized for speed rather that size. As a result, you will 
  25          see very few nested function calls. If speed is not critical, you 
  26          can use function calls for common tasks (like dat polling after 
  27          writing a byte to Flash or EEPROM) The penalty is the extra processor 
  28          time to make the nested calls.
  29          
  30          These files have been compiled using a C cross compiler from COSMIC 
  31          Software Inc. You may have to implement some syntax changes to be 
  32          compatible with other compilers. The intent of this generated C code 
  33          is to provide you with a core of useful broadbased functions that are 
  34          adaptable to many vendor's compilers and microcontrollers.
  35          
  36          
  37          NOTES:
  38          
  39          1. 
  40          Some of the routines provided may not have been thoroughly tested.  
  41          Please check them in your system. If you find a bug, or a place 
  42          where the code could be improved, PLEASE forward your comments by 
  43          emailing to apps.psd@st.com. Any comments and feedback are 
  44          appreciated. Please tell us what you like and or what you think 
  45          can be improved.
  46          
  47          Revision History:
  48          
  49          08/21/2002 (JAM) - Uncommented psd834f2.h include. Added #defines to 
  50                             enable flash routines used by firmware. Added xdata 
  51                             modifier to flash_write_with_poll pointer variables. 
  52                             Changed all variables named 'data' to 'dat' to avoid 
  53                             conflict with Keil compiler reserved word.
  54          
  55          */
C51 COMPILER V7.00 Beta 6  FLASHCODE1                                                      02/19/2003 15:59:28 PAGE 2   

  56          /* 
  57          Be sure to uncomment the associated #define statements inside the 
  58          header file, psd834f2.h, to use individual desired functions 
  59          contained in this file, psd834f2.c. Your compiler will ignore the functions
  60          in this file unless you do so.
  61          */
  62          
  63          #include "general.h"
  64          #include <psd834f2.h>   /*  uncomment this include statement 
  65                                      to use the header files generated by 
  66                                      PSDsoft */
  67          
  68          /* Function prototypes
  69          */
  70          
  71          #define _F_W_W_P
  72          #define _F_E_B
  73          #define _F_R
  74          
  75          
  76          unsigned char flash_write_with_poll(
  77              volatile unsigned char xdata *addr, unsigned char dat);
  78          unsigned char flash_erase_sector(
  79              volatile unsigned char xdata* flash_bulk_erase_address);
  80          unsigned char flash_boot_write_with_poll(
  81              volatile unsigned char xdata *addr, unsigned char dat);
  82          unsigned char flash_boot_erase_sector(
  83              volatile unsigned char xdata* flash_boot_bulk_erase_address);
  84          
  85          unsigned char flash_write_with_toggle(unsigned char *addr,unsigned char dat);
  86          void flash_reset(void); 
  87          unsigned char flash_read_id(unsigned char *flash_id_address);
  88          unsigned char flash_read_sector_protect(void);
  89          unsigned char flash_boot_write_with_toggle(volatile unsigned char *addr, 
  90          unsigned char dat);
  91          void flash_boot_reset(void);
  92          unsigned char flash_boot_read_id(volatile unsigned char *flash_boot_id_address);
  93          unsigned char flash_boot_read_sector_protect(void);     
  94          
  95          
  96          /* main_flash.c   
  97          
  98          - 12/20/99, msr
  99            >> New release.  Incorporates all prior revisions to C code.
 100          
 101          -1/6/00, msr
 102            >> Added delay of 3 msec after reset after flash error per dat sheet
 103            >> Notation updates for PSD9XXF
 104          
 105          - 4/27/01, msr
 106           >> Notation updates
 107          
 108          */
 109          
 110          
 111          /*
 112          Functions
 113          */
 114          
 115          /*
 116          Group: Main Flash Memory
 117          Coverage: Program, Erase, Reset, Read ID, Read Protection
C51 COMPILER V7.00 Beta 6  FLASHCODE1                                                      02/19/2003 15:59:28 PAGE 3   

 118          */
 119          
 120          
 121          /*
 122          Module: flash_write_with_poll
 123          Programs a single byte, checks status using polling method.
 124          You'll need to include the header files generated by PSDsoft
 125          Express. Important: if memory paging is used, the correct 
 126          page value must be set in the PSD page register prior to 
 127          calling this function.
 128          */
 129          
 130          #ifdef _F_W_W_P
 131          
 132          unsigned char flash_write_with_poll(volatile uchar xdata* addr, uchar dat)
 133          {
 134   1              unsigned char done;
 135   1              unsigned char error;
 136   1              unsigned char err;
 137   1              unsigned char poll;
 138   1      
 139   1              done = FALSE;
 140   1              err = FALSE;
 141   1      
 142   1              //  Note:  the following constants (FLASH_COMMON_XXXX)
 143   1              //     are declared type volatile in the header file 
 144   1              //         so they are not optimized away by the compiler
 145   1      
 146   1              
 147   1              *(FLASH_COMMON_X555) = 0xAA;     // unlock main flash, write 0xAA to addess 0xX555
 148   1              *(FLASH_COMMON_XAAA) = 0x55;     // unlock main flash, write 0x55 to addess 0xXAAA
 149   1              *(FLASH_COMMON_X555) = 0xA0;     // write 0xA0 command to program
 150   1      
 151   1              *(addr) = dat;                  // write byte to flash   
 152   1              
 153   1              dat = dat & NVM_DATA_POLL;     // get bit DQ7 of original dat   
 154   1              
 155   1              do                               // now use dat polling method to verify successful write
 156   1          {  
 157   2      
 158   2                      poll = *(addr);          // Read the location that was just programmed
 159   2      
 160   2                      error = poll & NVM_ERROR;   // save timeout error bit at DQ5
 161   2      
 162   2                      poll = poll & NVM_DATA_POLL;  // get DQ7 of poll byte read from flash  
 163   2      
 164   2                      if (dat == poll)        // compare DQ7 
 165   2      
 166   2                              done = TRUE;     // dat byte programmed into flash OK,
 167   2                                               // indicate successful exit criteria
 168   2      
 169   2                      else if (error ==  NVM_ERROR )   // check for timeout error   
 170   2                              err = TRUE;      // indicate timeout error occurred
 171   2      
 172   2          } while((done == FALSE) && (err == FALSE)); 
 173   1      
 174   1      
 175   1              if (err == TRUE)                 // make sure timeout error and dat poll didn't 
 176   1                                               // occur simultaneously
 177   1              {
 178   2                      poll = *(addr);          // Read location in flash again
 179   2      
C51 COMPILER V7.00 Beta 6  FLASHCODE1                                                      02/19/2003 15:59:28 PAGE 4   

 180   2                      poll = poll & NVM_DATA_POLL;   // get DQ7 of poll byte read from flash  
 181   2      
 182   2                      if (dat == poll)        // compare DQ7 
 183   2      
 184   2                              done = TRUE;     // dat byte programmed into flash OK at the same
 185   2                                               // time timout error occured, indicate successful 
 186   2                                              // exit criteria
 187   2      
 188   2                      *(FLASH_COMMON_X555) = 0xF0;  // reset the flash array (short reset instruction) 
 189   2                              // now delay 3 msec per dat sheet
 190   2          }
 191   1      
 192   1              return(done);         // a successful flash write returns 1, timeout error returns 0
 193   1      }
 194          
 195          unsigned char flash_boot_write_with_poll(volatile uchar xdata* addr, uchar dat)
 196          {
 197   1              unsigned char done;
 198   1              unsigned char error;
 199   1              unsigned char err;
 200   1              unsigned char poll;
 201   1      
 202   1              done = FALSE;
 203   1              err = FALSE;
 204   1      
 205   1              //  Note:  the following constants (FLASH_BOOT_XXXX)
 206   1              //     are declared type volatile in the header file 
 207   1              //         so they are not optimized away by the compiler
 208   1      
 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
 212   1              *(FLASH_BOOT_X555) = 0xA0;     // write 0xA0 command to program
 213   1      
 214   1              *(addr) = dat;                  // write byte to flash   

⌨️ 快捷键说明

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