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

📄 progctrl.psm

📁 利用picoblaze微控制器对Intel flash进行控制
💻 PSM
📖 第 1 页 / 共 5 页
字号:
                        LOAD UART_data, character_greater_than ;prompt for input
                        CALL send_to_UART
                        CALL read_upper_case
                        COMPARE s0, character_E                ;test for commands and execute as required
                        JUMP Z, erase_command
                        COMPARE s0, character_B
                        JUMP Z, block_erase_command
                        COMPARE s0, character_P
                        JUMP Z, program_command
                        COMPARE s0, character_W
                        JUMP Z, write_command
                        COMPARE s0, character_R
                        JUMP Z, read_command
                        COMPARE s0, character_I
                        JUMP Z, SF_information
                        COMPARE s0, character_H
                        JUMP Z, welcome_start
                        COMPARE s0, character_S
                        JUMP Z, SF_status
                        CALL send_CR                           ;no valid command input
                        LOAD UART_data, character_question     ;display ???
                        CALL send_to_UART
                        CALL send_to_UART
                        CALL send_to_UART
                        JUMP prompt                            ;Try again!
                        ;
                        ;
       read_upper_case: CALL read_from_UART                    ;read command character from UART
                        CALL send_to_UART                      ;echo character
                        LOAD s0, UART_data                     ;convert to upper case
                        CALL upper_case
                        RETURN
                        ;
                        ;
                        ;**************************************************************************************
                        ; Initialise the StrataFlash Memory control signals.
                        ;**************************************************************************************
                        ;
                        ; SF_read = 0   - Output enable off
                        ; SF_ce = 1     - Deselect StrataFLASH memory
                        ; SF_we = 1     - Write enable off
                        ;
                        ; Register used s0
                        ;
               SF_init: LOAD s0, 06
                        OUTPUT s0, SF_control_port
                        RETURN
                        ;
                        ;
                        ;**************************************************************************************
                        ; Erase Command - Perform bulk erase of the StrataFLASH memory
                        ;**************************************************************************************
                        ;
                        ; This routine executes the block erase command 128 times with a different base
                        ; address in each case.
                        ;
                        ; Note that this could take as long as 8 minutes 30 seconds
                        ; and even typical times will be approximately 2 minutes.
                        ;
                        ; Registers used s1,s7,s8,s9
                        ;
         erase_command: LOAD s9, FE                            ;define base address of block 127 = FE0000
                        JUMP blocks_erase
                        ;
                        ;
                        ;**************************************************************************************
                        ; Block Erase Command - Performs erase of lowest 3 blocks of StrataFLASH memory which
                        ; covers the address range 000000 to 05FFFF in which the configuration for an XC3S500E
                        ; would be able to fit (000000 to 045470).
                        ;**************************************************************************************
                        ;
                        ; This routine executes the block erase command 3 times with a different base
                        ; address in each case.
                        ;
                        ; Each block is 128K bytes and therefore has an address range of 000000 to 01FFFF.
                        ; So each block is separated by 020000 hex.
                        ;
                        ; Registers used s0,s1,s7,s8,s9
                        ;
   block_erase_command: LOAD s9, 04                            ;define base address of block 3 = 040000
          blocks_erase: CALL send_CR
                        CALL send_Confirm                      ;confirm command with a 'Y' which must be upper case
                        CALL read_from_UART                    ;read command character from UART
                        CALL send_to_UART                      ;echo input
                        COMPARE UART_data, character_Y
                        JUMP NZ, abort_erase
                        CALL send_CR
                        CALL send_Erase_in_progress
                        CALL send_CR
                        LOAD s8, 00                            ;define lower address of each block = xx0000
                        LOAD s7, 00
     blocks_erase_loop: LOAD UART_data, character_fullstop     ;progress dots
                        CALL send_to_UART
                        CALL SF_erase_block                    ;erase block
                        SUB s9, 02                             ;decrement base address by 1 block
                        JUMP NC, blocks_erase_loop             ;repeat until block 0 is erased
                        CALL send_OK
                        JUMP prompt
                        ;
           abort_erase: CALL send_Abort
                        JUMP prompt
                        ;
                        ;
                        ;**************************************************************************************
                        ; Erase a single 128K Byte block of the StrataFlash Memory
                        ;**************************************************************************************
                        ;
                        ; The 24-bit address of the block should be supplied in register set [s9,s8,s7].
                        ;
                        ; To erase a block the address must be set and then the block erase command (20 hex)
                        ; written to the memory followed by the write confirm command (D0 hex).
                        ;
                        ; The act of erasing a block may take up to 1 second to complete. This routine
                        ; waits for the memory to be ready before restoring the normal read array mode and
                        ; returning.
                        ;
                        ; Registers used s1,s7,s8,s9
                        ;
        SF_erase_block: LOAD s1, 20                            ;block erase command
                        CALL SF_byte_write
                        LOAD s1, D0                            ;write confirm command
                        CALL SF_byte_write
                        CALL wait_SF_ready                     ;wait for erase to complete
                        RETURN
                        ;
                        ;
                        ;**************************************************************************************
                        ; Program Command - Program StrataFLASH memory with data defined in an MCS file
                        ;**************************************************************************************
                        ;
       program_command: CALL send_CR
                        CALL send_Waiting_MCS_file
                        CALL program_MCS
                        CALL send_OK
                        JUMP prompt
                        ;
                        ;**************************************************************************************
                        ; Program StrataFLASH memory with data defined in an MCS file
                        ;**************************************************************************************
                        ;
                        ;Reads the MCS file from the UART and programs the Strata FLASH device at the locations.
                        ;specified by the file contents.
                        ;
                        ;This routine will continue until an end of file record is detected.
                        ;For each line of MCS received, the current address will be output so that
                        ;progress can be monitored.
                        ;
                        ;
           program_MCS: CALL read_MCS_line                     ;read line from UART
                        CALL MCS_address                       ;find start address and record type
                        COMPARE sB, 01                         ;test for end record
                        RETURN Z                               ;end of programming
                        COMPARE sB, 04                         ;test for extended address record
                        JUMP Z, program_MCS                    ;no data with this record and upper address now correct
                        ;
                        ;Assume data record type 00 which is data so need to program specified number
                        ;of bytes into memory at correct address.
                        ;
        write_spm_data: CALL send_hex_3bytes                   ;send address to indicate progress
                        CALL send_CR
                        FETCH sA, line_start                   ;read number of data bytes to program
                        CALL SF_buffer_write                   ;write bytes to memory
                        JUMP program_MCS
                        ;
                        ;
                        ;**************************************************************************************
                        ;Read one line of an MCS file into scratch pad memory
                        ;**************************************************************************************
                        ;
                        ;Reads one line of MCS file format into scratch pad memory starting at location 'line_start'.
                        ;
                        ;The routine detects the line start character ':' ignoring any preceding characters. This
                        ;will remove any additional CR or LF characters.
                        ;
                        ;It then reads each subsequent pair of ASCII characters, converts them to true hex in the
                        ;range 00 to FF and stores them in scratch pad memory.
                        ;
                        ;The end of the line is determined by either a CR or LF character.
                        ;
                        ;The value last returned in register 'sE' will be the pointer to the location in
                        ;scratch pad memory following the last byte for the line read.
                        ;
         read_MCS_line: LOAD sE, line_start                    ;initialise SPM memory pointer
   wait_MCS_line_Start: CALL read_from_UART                    ;read character
                        COMPARE UART_data, character_colon     ;test for start character
                        JUMP NZ, wait_MCS_line_Start
         read_MCS_byte: CALL read_from_UART                    ;read character
                        COMPARE UART_data, character_CR        ;test for end of line
                        RETURN Z
                        COMPARE UART_data, character_LF        ;test for end of line
                        RETURN Z
                        LOAD s3, UART_data                     ;upper nibble character
                        CALL read_from_UART                    ;read character
                        LOAD s2, UART_data                     ;lower nibble character
                        CALL ASCII_byte_to_hex                 ;convert to true hex value
                        STORE s0, (sE)                         ;write to SPM
                        ADD sE, 01                             ;increment pointer
                        JUMP read_MCS_byte
                        ;
                        ;
                        ;**************************************************************************************
                        ;Determine the current address for the line of an MCS file in scratch pad memory
                        ;**************************************************************************************
                        ;
                        ;Checks the existing line data stored in scratch pad memory starting at location
                        ;'line_start' and determines the current address.
                        ;

⌨️ 快捷键说明

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