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

📄 flashcode1.lst

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

 428          
 429          unsigned char flash_boot_erase_bulk(
 430              volatile unsigned char xdata* flash_bulk_erase_address)
 431          {
 432   1              unsigned char done;
 433   1              unsigned char poll;
 434   1              unsigned char error;
 435   1              unsigned char err;
 436   1      
 437   1              done = FALSE;
 438   1              err = FALSE;
 439   1      
 440   1              //  Note:  the following constants (FLASH_COMMON_XXXX)
 441   1              //     are declared type volatile in the header file 
 442   1              //         so they are not optimized away by the compiler
 443   1      
 444   1              *(FLASH_BOOT_X555) = 0xAA;              // unlock main flash, write 0xAA to addess 0xX555
 445   1              *(FLASH_BOOT_XAAA) = 0x55;              // unlock main flash, write 0x55 to addess 0xXAAA
 446   1              *(FLASH_BOOT_X555) = 0x80;              // write 0x80 command to erase entire chip
 447   1              *(FLASH_BOOT_X555) = 0xAA;              // continue unlock sequence
 448   1              *(FLASH_BOOT_XAAA) = 0x55;              // continue unlock sequence
 449   1              *(FLASH_BOOT_X555) = 0x10;              // write 0x10 command to complete erase command
 450   1      
 451   1              do                                      // now use dat polling method to verify successful erase
 452   1          {  
 453   2                      poll = *(flash_bulk_erase_address);     // read flash status from any address
 454   2                                                      // within the defined flash address space
 455   2      
 456   2                      error = poll & NVM_ERROR;       // save timeout error bit at DQ5
 457   2      
 458   2                      poll = poll & NVM_DATA_POLL;    // look at D7   
 459   2      
 460   2                      if (poll == NVM_DATA_POLL)      // compare DQ7 
 461   2      
 462   2                              done = TRUE;            // bulk erase OK,
 463   2                                                      // indicate successful exit criteria
 464   2      
 465   2                      else if (error == NVM_ERROR)    // check for timeout error   
 466   2                              err = TRUE;             // indicate timeout error occurred
 467   2      
 468   2          } while((done == FALSE) && (err == FALSE)); 
 469   1      
 470   1      
 471   1              if (err == TRUE)                        // make sure timeout error and dat poll didn't 
 472   1                                                      // occur simultaneously
 473   1          {
 474   2                      poll = *(flash_bulk_erase_address);     // Read flash status again
 475   2      
 476   2                      poll = poll & NVM_DATA_POLL;    // get DQ7 of poll byte read from flash  
 477   2      
 478   2                      if (poll == NVM_DATA_POLL)      // compare DQ7 
 479   2      
 480   2                              done = TRUE;            // the flash erased OK at the same
 481   2                                                      // time timout error occured, indicate successful 
 482   2                                                      // exit criteria
 483   2      
 484   2                      *(FLASH_BOOT_X555) = 0xF0;  // reset the flash array (short reset instruction) 
 485   2                              // now delay 3 msec per dat sheet
 486   2          }
 487   1      
 488   1              return(done);           // a successful flash erase returns 1, timeout error returns 0
 489   1      
C51 COMPILER V7.06   FLASHCODE1                                                            10/10/2004 20:51:48 PAGE 9   

 490   1      }
 491          
 492          #endif
 493          
 494          
 495          /*
 496          Module: flash_reset
 497          Resets the main Flash memory to Read Array mode.
 498          After this reset, the Flash memory may be read like a ROM device. 
 499          You'll need to include the header files generated by PSDsoft
 500          Express.
 501          */
 502          
 503          #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
                      }
              
              
              #endif
 522          
 523          
 524          /* 
 525          Module: flash_read_id
 526          Reads the Flash Identifier byte from main Flash memory. You'll need 
 527          to include the header files generated by PSDsoft Express.
 528          Important: The address passed to this function should be independent 
 529          of memory paging or else the PSD page register value should be set to 
 530          the correct page prior to calling this function.
 531          
 532          Note: The flash memory in the boot area of a PSD813F2 or PSD813F4 does 
 533          not provide an ID. Only the main Flash memory in all PSD813FX provides 
 534          an ID.
 535          */
 536          
 537          #ifdef _F_R_I
              
              unsigned char flash_read_id(flash_id_address)   // read flash identifier
              volatile unsigned char *flash_id_address;  
              
                      {
                      unsigned char id;
              
                      //  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
C51 COMPILER V7.06   FLASHCODE1                                                            10/10/2004 20:51:48 PAGE 10  

              
                      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
 563          
 564          
 565          /* 
 566          Module: flash_read_sector_protect
 567          Reads main Flash sector protection status.
 568          An unsigned char byte value is returned that contains the status 
 569          for all eight sectors of main Flash memory. This byte value can 
 570          be decoded as follows:
 571          
 572          BitD7   BitD6   BitD5   BitD4   BitD3   BitD2   BitD1   BitD0
 573           fs7     fs6     fs5     fs4     fs3     fs2     fs1     fs0
 574          
 575            fsx >> 1 = Flash sector is write protected
 576            fsx >> 0 = Flash sector is not write protected
 577          
 578          The protection bits may only be read by the microcontroller. They
 579          can be set or cleared only through the JTAG channel or a device
 580          programmer, not the microcontroller.
 581          
 582          
 583          Note:  You'll need to include the header files generated by PSDsoft
 584          Express. 
 585          */
 586          
 587          #ifdef _F_R_S_P
              
              unsigned char flash_read_sector_protect()       
              
                      {
               
                      return (MAINPROTECT.byte);   //This is a register inside the PSD
                                                      // For reference, see the header file 
                                                      // psd8xxfx.h for the location of 
                                                      // the PSD register, MAINPROTECT.
                      }
              
              #endif
 600          
 601          
 602          
 603          
 604          
 605           
 606          /* real_boot_flash.c   
 607          
 608          - 12/20/99, msr
 609            >> New release.  Incorporates all prior revisions to C code.
 610          
 611          -1/6/00, msr
 612            >> Added delay of 3 msec after reset after flash error per dat sheet
 613            >> Notation updates for PSD9XXF
C51 COMPILER V7.06   FLASHCODE1                                                            10/10/2004 20:51:48 PAGE 11  

 614          
 615          - 4/27/01, msr
 616           >> Notation updates
 617          
 618          
 619          */
 620          
 621          
 622          /*
 623          End of Group Main Flash Memory
 624          */


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