📄 sst49lf008a.txt
字号:
; carry bit: CLEARED means the block T_MINUS15 is erased
; carry bit: SET means the block T_MINUS15 cannot be erased
;=====================================================================
Erase_Block_T_MINUS15 proc near
push ax ; preserve registers?value
push es
pushf ; save interrupt state
cli
call Read_T_MINUS15_LK_Register ;read register value
and al, 3
cmp al, 3
je EBT2 ;locked down
cmp al, 1
jne EBT1 ;write protect
mov al, 0
call Write_T_MINUS15_LK_Register ;unlock the write protect
call Read_T_MINUS15_LK_Register
cmp al, 0
jne EBT2 ;unlock failed
EBT1:
mov es, FFF00000h ;point to a valid address of block T_MINUS15
call Erase_One_Block
pop ax
and ax, 0FFFEh ;block erased
jmp EBT3
EBT2:
pop ax
or ax, 1 ;block not erased
EBT3:
push ax
popf
pop es
pop ax
ret
Erase_Block_T_MINUS15 endp
; =====================================================================
; PROCEDURE: Program_One_Byte (FWH/PP Mode)
;
; This procedure can be used to program ONE byte of data to the 49LF008A.
;
; In FWH mode, the block containning the byte to be programmed needs to be
; unlocked first. Please refers the subroutine:
; Erase_Block_T_Minus15 for a detail of usage.
;
; NOTE: It is necessary to first erase the sector containing the byte
; to be programmed.
;
;
; Input:
; al BYTE which will be written into the 49LF008A.
; es:di DESTINATION address which will be written with the
; data input in al.
;
; Output:
; None
; ES, DI: Contain their original values
; =====================================================================
Program_One_Byte proc near
push ax ; save registers
push ds
mov ax, ABS_SEGMENT ; set up ds register
mov ds, ax
mov ds:byte ptr [5555h], 0AAh ; send 3 byte data protection
mov ds:byte ptr [2AAAh], 055h ; sequence to the chip
mov ds:byte ptr [5555h], 0A0h
pop ds
pop ax ; restore the byte to be
; programmed from stack
mov byte ptr es:[di], al ; program the byte
call check_Toggle_Ready ; wait for valid TOGGLE bit
ret
Program_One_Byte endp
; =====================================================================
; PROCEDURE: Program_One_Sector (FWH/PP Mode)
;
; This procedure can be used to program a memory sector, or total of
; 4096 bytes, of the 49LF008A.
;
; In FWH mode, the block containning the sector to be programmed needs to be
; unlocked first. Please refers the subroutine:
; Erase_Block_T_Minus15 for a detail of usage.
;
; Input:
; ds:si SOURCE address containing the data which will be
; written into the 49LF008A.
; es:di DESTINATION address which will be written with the
; data passed in for ds:si
;
; Output:
; None
; SI, DI: Contains their original values
; =====================================================================
Program_One_Sector proc near
push ax ; save registers
push bx
push cx
push di
push si
pushf ; preserve the "Direction" flag
cld ; clear "Direction" flag to
; auto-increment SI and DI
;
; Erase the sector before programming. Each erase command will erase a total
; of 4096 bytes for the 49LF008A
;
call Erase_One_Sector
;
; The following loop will program a total of 4096 bytes to the SST49LF008A
;
mov cx, SECTOR_SIZE
DRP1:
push ds
mov ax, ABS_SEGMENT
mov ds, ax
mov ds:byte ptr [5555h], 0AAh ; 3 bytes of "enable protection"
mov ds:byte ptr [2AAAh], 055h ; sequence to the chip
mov ds:byte ptr [5555h], 0A0h
pop ds
lodsb ; get the byte to be programmed
mov bx, di ; preserve original DI temporarily
stosb ; program the byte
push di ; preserve incremented DI temporarily
mov di, bx ; restore original DI
call check_Toggle_Ready ; wait for TOGGLE bit to get ready
pop di ; retrieve the updated DI
loopw DRP1 ; continue program more bytes until done
popf ; restore original direction flag
pop si ; restore registers
pop di
pop cx
pop bx
pop ax
ret
Program_One_Sector endp
; =====================================================================
; PROCEDURE: Program_One_Block (FWH/PP Mode)
;
; This procedure can be used to program a memory block, or a total of
; 64 Kbytes, of the SST49LF008A.
;
; In FWH mode, the block to be programmed needs to be unlocked first.
; Please refers the subroutine:
; Erase_Block_T_Minus15 for a detail of usage.
;
; Input:
; ds:si SOURCE address containing the data which will be
; written into the SST49LF008A.
; es:di DESTINATION address which will be written with the
; data passed in for ds:si
;
; Output:
; None
; SI, DI: Contains the original values
; =====================================================================
Program_One_Block proc near
push ax ; save registers
push bx
push di
push si
pushf ; preserve the "Direction" flag in the FLAG
; register
cld ; clear "Direction" flag in the FLAG register to
; auto-increment SI and DI
;
; Erase the block before programming. Each erase command will erase a total
; of 64K bytes of the SST49LF008A.
;
call Erase_One_Block
;
; The following loop will program a total of 64 Kbytes to SST's SST49LF008A
;
mov cx, BLOCK_SIZE
POB1:
push ds
mov ax, ABS_SEGMENT
mov ds, ax
mov ds:byte ptr [5555h], 0AAh ; send 3-byte SDP sequence
mov ds:byte ptr [2AAAh], 055h
mov ds:byte ptr [5555h], 0A0h
pop ds
lodsb ; get the byte to be programmed
mov bx, di ; preserve DI temporarily
stosb ; program the byte
push di ; preserve the updated DI temporarily
mov di, bx
call check_Toggle_Ready ; wait for TOGGLE bit to get ready
pop di ; retrieve the updated DI
loopw POB1 ; continue program more bytes until done
popf ; restore original direction flag
pop si ; restore registers
pop di
pop bx
pop ax
ret
Program_One_Block endp
;======================================================================
; PROCEDURE: Check_Toggle_Ready (FWH/PP Mode)
;
; During the internal program cycle, any consecutive read operation
; on DQ6 will produce alternating 0抯 and 1抯, i.e. toggling between
; 0 and 1. When the program cycle is completed, the DQ6 data will
; stop toggling. After the DQ6 data stops toggling, the device is ready
; for the next operation.
;
; Input:
; es:di must already be set-up by the caller
;
; Output:
; None
;======================================================================
Check_Toggle_Ready proc near
push ax ; save register
mov al, es:[di] ; read a byte from the chip
and al,40h ; mask out the TOGGLE bit (DQ6)
CTR_Tog2:
mov ah, es:[di] ; read the same byte from the chip again
and ah, 40h ; mask out the TOGGLE bit (DQ6)
cmp al, ah ; is DQ6 still toggling?
je CTR_Tog3 ; No, then the write operation is done
xchg ah, al ; YES, then continue checking...
jmp short CTR_Tog2
CTR_Tog3:
pop ax ; restore register
ret
Check_Toggle_Ready endp
;=======================================================================
; PROCEDURE: Check_Data_Polling (FWH/PP Mode)
;
; During the internal program cycle, any attempt to read DQ7 of the last
; byte loaded during the page/byte-load cycle will receive the complement
; of the true data. Once the program cycle is completed, DQ7 will show
; true data.
;
; Input:
; es:di must already be set-up by the caller
; bl contains the original (true) data
;
; Output:
; None
;
;=======================================================================
Check_Data_Polling proc near
push ax ; save registers
push bx
and bl, 80h ; mask out the DQ7 bit
CDP_Tog2:
mov al, es:[di] ; read a byte from the chip
and al,80h ; mask out the DQ7 bit
cmp al,bl ; is DQ7 still complementing?
jne CDP_Tog2
pop bx ; restore registers
pop ax
ret
Check_Data_Polling endp
;=======================================================================
; PROCEDURE: Read_SST49LF008A_GPI_Rigister (FWH Mode)
;
; This procedure fetches the content of GPI Reigster of the device,
; which is in the address 0xFFBC0100. It's recommended that the
; GPI[4:0] pins be in the desired state before LFRAME# is brought low
; for the beginning of the next bus cycle, and remain in that state
; until the end of the cycle.
;
; Input:
; None
; Output:
; GPI register value will be in AL
;=======================================================================
Read_SST49LF008A_GPI_Rigister proc near
mov al,byte ptr[SST_49LF008A_GPI] ;store GPI value to AL
ret
Read_SST49LF008A_GPI_Rigister endp
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -