📄 sst39vf400a.txt
字号:
; that is, a multiple of 2048.
;
; Output:
; None
; =====================================================================
Erase_One_Sector proc near
push ax ; save register
mov es:word ptr [5555h], 0AAAAh ; send 6-byte code for
mov es:word ptr [2AAAh], 05555h ; sector erase
mov es:word ptr [5555h], 08080h
mov es:word ptr [5555h], 0AAAAh
mov es:word ptr [2AAAh], 05555h
mov ax, 03030h
mov word ptr es:[di], ax
call Delay_25_Milli_Seconds ; insert delay = Tse
pop ax ; restore register
ret
Erase_One_Sector endp
; =====================================================================
; PROCEDURE: Erase_One_Block
;
; This procedure can be used to erase a block, or total of 32K words,
; in the SST39VF400A.
;
; Input:
; es:di points to the beginning address of the "Destination"
; block which will be erased.
; ==> Note: The address MUST be on a block boundary,
; that is, a multiple of 32K.
;
; Output:
; None
; =====================================================================
Erase_One_Block proc near
push ax ; save register
mov es:word ptr [5555h], 0AAAAh ; send 6-byte code for
mov es:word ptr [2AAAh], 05555h ; block erase
mov es:word ptr [5555h], 08080h
mov es:word ptr [5555h], 0AAAAh
mov es:word ptr [2AAAh], 05555h
mov ax, 05050h
mov word ptr es:[di], ax
call Delay_25_Milli_Seconds ; insert delay = Tbe
pop ax ; restore register
ret
Erase_One_Block endp
; =====================================================================
; PROCEDURE: Erase_Entire_Chip
;
; This procedure can be used to erase the entire contents of
; SST's SST39VF400A.
;
; Input:
; none
;
; Output:
; None
; =====================================================================
Erase_Entire_Chip proc near
mov es:word ptr [5555h], 0AAAAh ; send 6-byte code for
mov es:word ptr [2AAAh], 05555h ; chip erase
mov es:word ptr [5555h], 08080h
mov es:word ptr [5555h], 0AAAAh
mov es:word ptr [2AAAh], 05555h
mov es:word ptr [5555h], 01010h
call Delay_100_Milli_Seconds ; insert delay = Tsce
ret
Erase_Entire_Chip endp
; =====================================================================
; PROCEDURE: Program_One_Word
;
; This procedure can be used to program ONE word of data to the SST39VF400A.
;
; NOTE: It is necessary to first erase the sector containing the word to
; be programmed.
;
;
; Input:
; ax WORD which will be written into the SST39VF400A.
; es:di DESTINATION address which will be written with the
; data input in ax.
;
; Output:
; None
; SI, DI: Contain their original values
; =====================================================================
Program_One_Word proc near
push ax ; save registers
push ds
mov ax, ABS_SEGMENT ; set up the ds register
mov ds, ax
mov ds:word ptr [5555h], 0AAAAh ; send 3 byte data protection
mov ds:word ptr [2AAAh], 05555h ; sequence to the chip
mov ds:word ptr [5555h], 0A0A0h
pop ds ; restore the byte to be
pop ax ; programmed from stack
mov word ptr es:[di], ax ; program the byte
call check_Toggle_Ready ; wait for valid TOGGLE bit
ret
Program_One_Word endp
; =====================================================================
; PROCEDURE: Program_One_Sector
;
; This procedure can be used to program a memory sector, or total of
; 2048 words, of the SST39VF400A.
;
; Input:
; ds:si SOURCE address containing the data which will be
; written into the SST39VF400A.
; es:di DESTINATION address which will be written with the
; data passed in for ds:si
;
; Output:
; None
; SI, DI: Contain their original values
; =====================================================================
Program_One_Sector proc near
push ax ; save registers
push bx
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 2048 words for the SST39VF400A
;
call Erase_One_Sector
;
; The following loop will program a total of 2048 words to the SST39VF400A
;
mov cx, SECTOR_SIZE
POS1:
push ds
mov ax, ABS_SEGMENT
mov ds, ax
mov ds:word ptr [5555h], 0AAAAh ; send 3-byte SDP sequence
mov ds:word ptr [2AAAh], 05555h
mov ds:word ptr [5555h], 0A0A0h
pop ds
lodsw ; get the word to be programmed
mov bx, di ; preserve original DI temporarily
stosw ; program the word
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
loop POS1 ; continue program more words until done
;
; Restore the registers' value from the stack
;
popf ; restore original direction flag
pop si ; restore registers
pop di
pop bx
pop ax
ret
Program_One_Sector endp
; =====================================================================
; PROCEDURE: Program_One_Block
;
; This procedure can be used to program a memory block, or a total of
; 32K words, of the SST39VF400A.
;
; Input:
; ds:si SOURCE address containing the data which will be
; written into the SST39VF400A.
; es:di DESTINATION address which will be written with the
; data passed in for ds:si
;
; Output:
; None
; SI, DI: Contain their original values
; =====================================================================
Program_One_Block proc near
push ax ; save registers
push bx
push di
push si
pushf ; preserve the "Direction" flag
cld ; clear "Direction" flag to
; auto-increment SI and DI
;
; Erase the block before programming. Each erase command will erase a total
; of 32K words of the SST39VF400A.
;
call Erase_One_Block
;
; The following loop will program a total of 32K words to SST's SST39VF400A
;
mov cx, BLOCK_SIZE
POB1:
push ds
mov ax, ABS_SEGMENT
mov ds, ax
mov ds:word ptr [5555h], 0AAAAh ; send 3-byte SDP sequence
mov ds:word ptr [2AAAh], 05555h
mov ds:word ptr [5555h], 0A0A0h
pop ds
lodsw ; get the word to be programmed
mov bx, di ; preserve DI temporarily
stosw ; program the word
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
loop POB1 ; continue program more words 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
;
; 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 registers
push bx
mov ax, es:[di] ; read a word from the chip
and ax, 4040h ; mask out the TOGGLE bit (DQ6)
CTR_Tog2:
mov bx, es:[di] ; read the same word from the chip again
and bx, 4040h ; mask out the TOGGLE bit (DQ6)
cmp ax, bx ; is DQ6 still toggling?
je CTR_Tog3 ; No, then the write operation is done
xchg ax, bx ; YES, then continue checking...
jmp short CTR_Tog2
CTR_Tog3:
pop bx ; restore registers
pop ax
ret
Check_Toggle_Ready endp
;=======================================================================
; PROCEDURE: Check_Data_Polling
;
; 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
; bx contains the original (true) data
;
; Output:
; None
;
;=======================================================================
Check_Data_Polling proc near
push ax ; save registers
push bx
and bx, 8080h ; mask out the DQ7 bit
CDP_Tog2:
mov ax, es:[di] ; read a word from the chip
and ax, 8080h ; mask out the DQ7 bit
cmp ax, bx ; is DQ7 still complementing?
jne CDP_Tog2
pop bx ; restore registers
pop ax
ret
Check_Data_Polling endp
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -