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

📄 flashcode1.lst

📁 upsd 3200序列的usb驱动
💻 LST
📖 第 1 页 / 共 3 页
字号:
 436   1              unsigned char done;
 437   1              unsigned char poll;
 438   1              unsigned char error;
 439   1              unsigned char err;
 440   1      
 441   1              done = FALSE;
 442   1              err = FALSE;
 443   1      
 444   1              //  Note:  the following constants (FLASH_COMMON_XXXX)
 445   1              //     are declared type volatile in the header file 
 446   1              //         so they are not optimized away by the compiler
 447   1      
 448   1              *(FLASH_BOOT_X555) = 0xAA;              // unlock main flash, write 0xAA to addess 0xX555
 449   1              *(FLASH_BOOT_XAAA) = 0x55;              // unlock main flash, write 0x55 to addess 0xXAAA
 450   1              *(FLASH_BOOT_X555) = 0x80;              // write 0x80 command to erase entire chip
 451   1              *(FLASH_BOOT_X555) = 0xAA;              // continue unlock sequence
 452   1              *(FLASH_BOOT_XAAA) = 0x55;              // continue unlock sequence
 453   1              // *(FLASH_BOOT_X555) = 0x10;           // write 0x10 command to complete erase command
 454   1          *(flash_bulk_erase_address) = 0x30; // write 0x30 to sector address to erase
 455   1      
 456   1              do                                      // now use dat polling method to verify successful erase
 457   1          {  
 458   2                      poll = *(flash_bulk_erase_address);     // read flash status from any address
 459   2                                                      // within the defined flash address space
 460   2      
 461   2                      error = poll & NVM_ERROR;       // save timeout error bit at DQ5
 462   2      
 463   2                      poll = poll & NVM_DATA_POLL;    // look at D7   
 464   2      
 465   2                      if (poll == NVM_DATA_POLL)      // compare DQ7 
 466   2      
 467   2                              done = TRUE;            // bulk erase OK,
 468   2                                                      // indicate successful exit criteria
 469   2      
 470   2                      else if (error == NVM_ERROR)    // check for timeout error   
 471   2                              err = TRUE;             // indicate timeout error occurred
 472   2      
 473   2          } while((done == FALSE) && (err == FALSE)); 
 474   1      
 475   1      
 476   1              if (err == TRUE)                        // make sure timeout error and dat poll didn't 
 477   1                                                      // occur simultaneously
 478   1          {
 479   2                      poll = *(flash_bulk_erase_address);     // Read flash status again
 480   2      
 481   2                      poll = poll & NVM_DATA_POLL;    // get DQ7 of poll byte read from flash  
 482   2      
 483   2                      if (poll == NVM_DATA_POLL)      // compare DQ7 
 484   2      
 485   2                              done = TRUE;            // the flash erased OK at the same
 486   2                                                      // time timout error occured, indicate successful 
 487   2                                                      // exit criteria
 488   2      
 489   2                      *(FLASH_BOOT_X555) = 0xF0;  // reset the flash array (short reset instruction) 
C51 COMPILER V7.00 Beta 6  FLASHCODE1                                                      02/19/2003 15:59:28 PAGE 9   

 490   2                              // now delay 3 msec per dat sheet
 491   2          }
 492   1      
 493   1              return(done);           // a successful flash erase returns 1, timeout error returns 0
 494   1      
 495   1      }
 496          
 497          #endif
 498          
 499          
 500          /*
 501          Module: flash_reset
 502          Resets the main Flash memory to Read Array mode.
 503          After this reset, the Flash memory may be read like a ROM device. 
 504          You'll need to include the header files generated by PSDsoft
 505          Express.
 506          */
 507          
 508          #ifdef _F_R
 509          
 510          void flash_reset()      // reset flash, read array mode
 511          
 512                  {
 513   1      
 514   1              //  Note:  the following constants (FLASH_COMMON_XXXX)
 515   1              //     are declared type volatile in the header file 
 516   1              //         so they are not optimized away by the compiler
 517   1      
 518   1              *(FLASH_COMMON_X555) = 0xAA;            // unlock main flash, write 0xAA to addess 0xX555
 519   1              *(FLASH_COMMON_XAAA) = 0x55;            // unlock main flash, write 0x55 to addess 0xXAAA
 520   1              *(FLASH_COMMON_X555) = 0xF0;            // write 0xF0 command to reset 
 521   1                                                      // Flash memory to Read Array Mode
 522   1                            // now delay 3 msec per dat sheet
 523   1              }
 524          
 525          void flash_boot_reset() // reset boot flash, read array mode
 526          
 527                  {
 528   1      
 529   1              //  Note:  the following constants (FLASH_BOOT_XXXX)
 530   1              //     are declared type volatile in the header file 
 531   1              //         so they are not optimized away by the compiler
 532   1      
 533   1              *(FLASH_BOOT_X555) = 0xAA;              // unlock main flash, write 0xAA to addess 0xX555
 534   1              *(FLASH_BOOT_XAAA) = 0x55;              // unlock main flash, write 0x55 to addess 0xXAAA
 535   1              *(FLASH_BOOT_X555) = 0xF0;              // write 0xF0 command to reset 
 536   1                                                      // Flash memory to Read Array Mode
 537   1                            // now delay 3 msec per dat sheet
 538   1              }
 539          
 540          #endif
 541          
 542          
 543          /* 
 544          Module: flash_read_id
 545          Reads the Flash Identifier byte from main Flash memory. You'll need 
 546          to include the header files generated by PSDsoft Express.
 547          Important: The address passed to this function should be independent 
 548          of memory paging or else the PSD page register value should be set to 
 549          the correct page prior to calling this function.
 550          
 551          Note: The flash memory in the boot area of a PSD813F2 or PSD813F4 does 
C51 COMPILER V7.00 Beta 6  FLASHCODE1                                                      02/19/2003 15:59:28 PAGE 10  

 552          not provide an ID. Only the main Flash memory in all PSD813FX provides 
 553          an ID.
 554          */
 555          
 556          #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
              
                      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
 582          
 583          
 584          /* 
 585          Module: flash_read_sector_protect
 586          Reads main Flash sector protection status.
 587          An unsigned char byte value is returned that contains the status 
 588          for all eight sectors of main Flash memory. This byte value can 
 589          be decoded as follows:
 590          
 591          BitD7   BitD6   BitD5   BitD4   BitD3   BitD2   BitD1   BitD0
 592           fs7     fs6     fs5     fs4     fs3     fs2     fs1     fs0
 593          
 594            fsx >> 1 = Flash sector is write protected
 595            fsx >> 0 = Flash sector is not write protected
 596          
 597          The protection bits may only be read by the microcontroller. They
 598          can be set or cleared only through the JTAG channel or a device
 599          programmer, not the microcontroller.
 600          
 601          
 602          Note:  You'll need to include the header files generated by PSDsoft
 603          Express. 
 604          */
 605          
 606          #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 
C51 COMPILER V7.00 Beta 6  FLASHCODE1                                                      02/19/2003 15:59:28 PAGE 11  

                                                      // psd8xxfx.h for the location of 
                                                      // the PSD register, MAINPROTECT.
                      }
              
              #endif
 619          
 620          
 621          
 622          
 623          
 624           
 625          /* real_boot_flash.c   
 626          
 627          - 12/20/99, msr
 628            >> New release.  Incorporates all prior revisions to C code.
 629          
 630          -1/6/00, msr
 631            >> Added delay of 3 msec after reset after flash error per dat sheet
 632            >> Notation updates for PSD9XXF
 633          
 634          - 4/27/01, msr
 635           >> Notation updates
 636          
 637          
 638          */
 639          
 640          
 641          /*
 642          End of Group Main Flash Memory
 643          */


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