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

📄 flash.lst

📁 本程序是一个RS232转网口的。是一个透明传输的模块
💻 LST
📖 第 1 页 / 共 2 页
字号:
                      *(FLASH_COMMON_XAAA) = 0x55;            // continue unlock sequence
                      //*(FLASH_COMMON_X555) = 0x10;          // write 0x10 command to complete erase command
                  *(flash_bulk_erase_address) = 0x30; // write 0x30 to sector address to erase
              
                      do                                      // now use dat polling method to verify successful erase
                  {  
                              poll = *(flash_bulk_erase_address);     // read flash status from any address
                                                              // within the defined flash address space
              
                              error = poll & NVM_ERROR;       // save timeout error bit at DQ5
              
                              poll = poll & NVM_DATA_POLL;    // look at D7   
              
                              if (poll == NVM_DATA_POLL)      // compare DQ7 
              
                                      done = TRUE;            // bulk erase OK,
                                                              // indicate successful exit criteria
              
                              else if (error == NVM_ERROR)    // check for timeout error   
                                      err = TRUE;             // indicate timeout error occurred
              
                  } while((done == FALSE) && (err == FALSE)); 
              
              
                      if (err == TRUE)                        // make sure timeout error and dat poll didn't 
                                                              // occur simultaneously
                  {
                              poll = *(flash_bulk_erase_address);     // Read flash status again
              
                              poll = poll & NVM_DATA_POLL;    // get DQ7 of poll byte read from flash  
              
                              if (poll == NVM_DATA_POLL)      // compare DQ7 
              
                                      done = TRUE;            // the flash erased OK at the same
                                                              // time timout error occured, indicate successful 
                                                              // exit criteria
              
                              *(FLASH_COMMON_X555) = 0xF0;  // reset the flash array (short reset instruction) 
                                      // now delay 3 msec per dat sheet
                  }
              
                      return(done);           // a successful flash erase returns 1, timeout error returns 0
              
              }
              #endif
 299          
 300          
 301          /*
 302          *****************************************************************************************************
C51 COMPILER V7.06   FLASH                                                                 09/26/2008 13:35:54 PAGE 6   

 303          * 
 304          *****************************************************************************************************
 305          */
 306          #ifdef _F_B_E_B
 307          
 308          unsigned char flash_boot_erase_sector(
 309              volatile unsigned char xdata* flash_bulk_erase_address)
 310          {
 311   1              unsigned char done;
 312   1              unsigned char poll;
 313   1              unsigned char error;
 314   1              unsigned char err;
 315   1      
 316   1              done = FALSE;
 317   1              err = FALSE;
 318   1      
 319   1              //  Note:  the following constants (FLASH_COMMON_XXXX)
 320   1              //     are declared type volatile in the header file 
 321   1              //         so they are not optimized away by the compiler
 322   1      
 323   1              *(FLASH_BOOT_X555) = 0xAA;              // unlock main flash, write 0xAA to addess 0xX555
 324   1              *(FLASH_BOOT_XAAA) = 0x55;              // unlock main flash, write 0x55 to addess 0xXAAA
 325   1              *(FLASH_BOOT_X555) = 0x80;              // write 0x80 command to erase entire chip
 326   1              *(FLASH_BOOT_X555) = 0xAA;              // continue unlock sequence
 327   1              *(FLASH_BOOT_XAAA) = 0x55;              // continue unlock sequence
 328   1              // *(FLASH_BOOT_X555) = 0x10;           // write 0x10 command to complete erase command
 329   1          *(flash_bulk_erase_address) = 0x30; // write 0x30 to sector address to erase
 330   1      
 331   1              do                                      // now use dat polling method to verify successful erase
 332   1          {  
 333   2                      poll = *(flash_bulk_erase_address);     // read flash status from any address
 334   2                                                      // within the defined flash address space
 335   2      
 336   2                      error = poll & NVM_ERROR;       // save timeout error bit at DQ5
 337   2      
 338   2                      poll = poll & NVM_DATA_POLL;    // look at D7   
 339   2      
 340   2                      if (poll == NVM_DATA_POLL)      // compare DQ7 
 341   2      
 342   2                              done = TRUE;            // bulk erase OK,
 343   2                                                      // indicate successful exit criteria
 344   2      
 345   2                      else if (error == NVM_ERROR)    // check for timeout error   
 346   2                              err = TRUE;             // indicate timeout error occurred
 347   2      
 348   2          } while((done == FALSE) && (err == FALSE)); 
 349   1      
 350   1      
 351   1              if (err == TRUE)                        // make sure timeout error and dat poll didn't 
 352   1                                                      // occur simultaneously
 353   1          {
 354   2                      poll = *(flash_bulk_erase_address);     // Read flash status again
 355   2      
 356   2                      poll = poll & NVM_DATA_POLL;    // get DQ7 of poll byte read from flash  
 357   2      
 358   2                      if (poll == NVM_DATA_POLL)      // compare DQ7 
 359   2      
 360   2                              done = TRUE;            // the flash erased OK at the same
 361   2                                                      // time timout error occured, indicate successful 
 362   2                                                      // exit criteria
 363   2      
 364   2                      *(FLASH_BOOT_X555) = 0xF0;  // reset the flash array (short reset instruction) 
C51 COMPILER V7.06   FLASH                                                                 09/26/2008 13:35:54 PAGE 7   

 365   2                              // now delay 3 msec per dat sheet
 366   2          }
 367   1      
 368   1              return(done);           // a successful flash erase returns 1, timeout error returns 0
 369   1      
 370   1      }
 371          
 372          #endif
 373          
 374          /*
 375          *****************************************************************************************************
 376          * 
 377          *****************************************************************************************************
 378          */
 379          #ifdef _F_R
              
              void flash_reset()      // reset flash, read array mode
              
                      {
              
                      //  Note:  the following constants (FLASH_COMMON_XXXX)
                      //     are declared type volatile in the header file 
                      //         so they are not optimized away by the compiler
              
                      *(FLASH_COMMON_X555) = 0xAA;            // unlock main flash, write 0xAA to addess 0xX555
                      *(FLASH_COMMON_XAAA) = 0x55;            // unlock main flash, write 0x55 to addess 0xXAAA
                      *(FLASH_COMMON_X555) = 0xF0;            // write 0xF0 command to reset 
                                                              // Flash memory to Read Array Mode
                                    // now delay 3 msec per dat sheet
                      }
              
              void flash_boot_reset() // reset boot flash, read array mode
              
                      {
              
                      //  Note:  the following constants (FLASH_BOOT_XXXX)
                      //     are declared type volatile in the header file 
                      //         so they are not optimized away by the compiler
              
                      *(FLASH_BOOT_X555) = 0xAA;              // unlock main flash, write 0xAA to addess 0xX555
                      *(FLASH_BOOT_XAAA) = 0x55;              // unlock main flash, write 0x55 to addess 0xXAAA
                      *(FLASH_BOOT_X555) = 0xF0;              // write 0xF0 command to reset 
                                                              // Flash memory to Read Array Mode
                                    // now delay 3 msec per dat sheet
                      }
              
              #endif
 412          
 413          
 414          /*
 415          *****************************************************************************************************
 416          * 
 417          *****************************************************************************************************
 418          */
 419          #ifdef _F_R_I
              
              unsigned char flash_read_id(flash_id_address)   // read flash identifier
              volatile unsigned char *flash_id_address;  
              
                      {
                      unsigned char id;
              
C51 COMPILER V7.06   FLASH                                                                 09/26/2008 13:35:54 PAGE 8   

                      //  Note:  the following constants (FLASH_COMMON_XXXX)
                      //     are declared type volatile in the header file 
                      //         so they are not optimized away by the compiler
              
                      *(FLASH_COMMON_X555) = 0xAA;            // unlock main flash, write 0xAA to addess 0xX555
                      *(FLASH_COMMON_XAAA) = 0x55;            // unlock main flash, write 0x55 to addess 0xXAAA
                      *(FLASH_COMMON_X555) = 0x90;            // write 0x90 command to get ID
              
                      id = *(flash_id_address);               // read flash status, address bit A6 = 0
                                                              //                                A1 = 0
                                                              //                                A0 = 1
                      *(FLASH_COMMON_X555) = 0xF0;  // reset the flash array (short reset instruction) 
                                      // now delay 3 msec per dat sheet
              
                      return (id);                            // return byte ID value
                      }
              
              #endif
 445          
 446          
 447          /*
 448          *****************************************************************************************************
 449          * 
 450          *****************************************************************************************************
 451          */
 452          #ifdef _F_R_S_P
              
              extern xdata PSD_REGS PSD_reg;// _at_ PSD_REG_ADDR;     // Define PSD registers at address "csiop" space
              
              unsigned char flash_read_sector_protect()       
              
                      {
               
                      return (PSD_reg.MAINPROTECT);   //This is a register inside the PSD
                                                      // For reference, see the header file 
                                                      // upsd3200.h for the location of 
                                                      // the PSD register, MAINPROTECT.
                      }
              
              #endif
 467          
 468          
 469          
 470          
 471          /*
 472          *****************************************************************************************************
 473          *FUNC: 
 474          *NOTE:  
 475          *****************************************************************************************************
 476          */
 477          unsigned char xdata bootdptr _at_ 0x7E00;
 478          
 479          void ReadFlash(unsigned char xdata *dest,unsigned int length)
 480          {
 481   1               unsigned int i=0;
 482   1           unsigned char xdata *read_add = bootdptr;
 483   1      
 484   1               for (i=0; i<length; i++) {
 485   2               *dest++ = *read_add++;
 486   2               }
 487   1      }
 488          
C51 COMPILER V7.06   FLASH                                                                 09/26/2008 13:35:54 PAGE 9   

 489          void WriteFlash(unsigned char xdata *source,unsigned int length)
 490          {
 491   1               unsigned int i=0;
 492   1           unsigned char xdata *write_add = bootdptr;
 493   1      
 494   1               flash_boot_erase_sector(write_add);
 495   1               for (i=0; i<length; i++) {
 496   2               flash_boot_write_with_poll(write_add++,*source++);
 497   2               }
 498   1      }
 499          
 500          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    341    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----      14
   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 + -