|
楼主 |
发表于 2011-2-23 16:10:55
|
显示全部楼层
这是部分擦除的程序
CONSTANT FLASH_data_in_port, 02 ;Read data from FLASH device
;
CONSTANT FLASH_data_out_port, 10 ;Data to write into FLASH device
;
CONSTANT FLASH_addr_hi_port, 80 ;FLASH address[23:16]
CONSTANT FLASH_addr_mi_port, 40 ;FLASH address[15:8]
CONSTANT FLASH_addr_lo_port, 20 ;FLASH address[7:0]
;
CONSTANT FLASH_control_port, 08 ;FLASH control
CONSTANT FLASH_read, 01 ; active High read - bit0
CONSTANT FLASH_ce, 02 ; active Low device enable - bit1
CONSTANT FLASH_we, 04 ; active Low write - bit2
NAMEREG sF, UART_data ;used to pass data to and from the UART
;erase chip command sequence
;
LOAD s9, 00
LOAD s8, 0A
LOAD s7, AA
LOAD s1, AA
CALL FLASH_byte_write
LOAD s8, 05
LOAD s7, 55
LOAD s1, 55
CALL FLASH_byte_write
LOAD s8, 0A
LOAD s7, AA
LOAD s1, 80
CALL FLASH_byte_write
LOAD s8, 0A
LOAD s7, AA
LOAD s1, AA
CALL FLASH_byte_write
LOAD s8, 05
LOAD s7, 55
LOAD s1, 55
CALL FLASH_byte_write
LOAD s8, 0A
LOAD s7, AA
LOAD s1, 10
CALL FLASH_byte_write
;
;wait for erase to complete by polling status register
;
chip_erase_loop: CALL FLASH_byte_read ;read status register
TEST s0, 80 ;test MSB
JUMP NZ, end_chip_erase
LOAD UART_data, character_fullstop ;progress dots
CALL send_to_UART
CALL delay_1s
JUMP chip_erase_loop
;
end_chip_erase: CALL send_CR
CALL send_OK
JUMP prompt
;
abort_chip_erase: CALL send_Abort
JUMP prompt
FLASH_byte_write: OUTPUT s9, FLASH_addr_hi_port ;set 24-bit address
OUTPUT s8, FLASH_addr_mi_port
OUTPUT s7, FLASH_addr_lo_port
OUTPUT s1, FLASH_data_out_port ;set data byte to be written
LOAD s1, 00 ;set controls
OUTPUT s1, FLASH_control_port
LOAD s1, 06 ;>45ns delay
LOAD s1, 06 ; but do something useful by preparing register!
OUTPUT s1, FLASH_control_port ;clear controls
RETURN
FLASH_byte_read: OUTPUT s9, FLASH_addr_hi_port ;set 24-bit address
OUTPUT s8, FLASH_addr_mi_port
OUTPUT s7, FLASH_addr_lo_port
LOAD s1, 05 ;set controls
OUTPUT s1, FLASH_control_port
LOAD s1, 06 ;>70ns delay
LOAD s1, 06 ; but do something useful by preparing register!
INPUT s0, FLASH_data_in_port ;read data byte
OUTPUT s1, FLASH_control_port ;clear controls
RETURN |
|