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

📄 sst39vf016.txt

📁 sst39vf016驱动程序
💻 TXT
📖 第 1 页 / 共 3 页
字号:

        mov     es:byte ptr [5555h], 0AAh	; send 6-byte code for
        mov     es:byte ptr [2AAAh], 055h	;  sector erase
        mov     es:byte ptr [5555h], 080h
        mov     es:byte ptr [5555h], 0AAh
        mov     es:byte ptr [2AAAh], 055h
        mov     al, 030h
        mov     byte ptr es:[di], al

        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 64K bytes,
; in the SST39VF016.
;
; 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 64K.
;
; Output:
;       None
; =====================================================================

Erase_One_Block         proc    near

        push    ax                              ; save register

        mov     es:byte ptr [5555h], 0AAh	; send 6-byte code for
        mov     es:byte ptr [2AAAh], 055h	;  block erase
        mov     es:byte ptr [5555h], 080h
        mov     es:byte ptr [5555h], 0AAh
        mov     es:byte ptr [2AAAh], 055h
        mov     al, 050h
        mov     byte ptr es:[di], al

        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 SST39VF016.
;
; Input:
;       none
;
; Output:
;       None
; =====================================================================

Erase_Entire_Chip       proc    near

        mov     es:byte ptr [5555h], 0AAh	  ; send 6-byte code for
        mov     es:byte ptr [2AAAh], 055h	  ;  chip erase
        mov     es:byte ptr [5555h], 080h
        mov     es:byte ptr [5555h], 0AAh
        mov     es:byte ptr [2AAAh], 055h
        mov     es:byte ptr [5555h], 010h

        call    Delay_100_Milli_Seconds	          ; insert delay = Tsce

        ret

Erase_Entire_Chip       endp


; =====================================================================
; PROCEDURE:    Program_One_Byte
;
; This procedure can be used to program ONE byte of data to the SST39VF016.
;
; NOTE:  It is necessary to first erase the sector containing the byte to
;        be programmed
;
;
; Input:
;       al      BYTE which will be written into the SST39VF016.
;       es:di   DESTINATION address which will be written with the
;               data input in al.
;
; Output:
;       None
;       SI, DI  Contain original values
; =====================================================================

Program_One_Byte          proc    near

        push    ax                           ; save registers
        push    ds
        mov     ax, ABS_SEGMENT              ; set up the 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                           ; restore registers
        pop     ax                     
        mov     byte ptr es:[di], al         ; program the byte
        call    check_Toggle_Ready           ; wait for TOGGLE bit to be valid

        ret

Program_One_Byte          endp


; =====================================================================
; PROCEDURE:    Program_One_Sector
;
; This procedure can be used to program a memory sector, or total of 
; 4096 bytes, of the SST39VF016.
;
; Input:
;       ds:si   SOURCE address containing the data which will be
;               written into the SST39VF016.
;       es:di   DESTINATION address which will be written with the
;               data passed in for ds:si
;
; Output:
;       None
;       SI, DI  Contain original values
; =====================================================================

Program_One_Sector        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
                                ; auto-increment SI and DI
;
; Erase the sector before programming.  Each erase command will erase a total
; of 4096 bytes for the SST39VF016
;
        call    Erase_One_Sector
;
; The following loop will program a total of 4096 bytes to the SST39VF016
;
        mov     cx, SECTOR_SIZE
POS1:
        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
        loop    POS1                    ; continue program more bytes 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 
; 64K bytes, of the SST39VF016.
;
; Input:
;       ds:si   SOURCE address containing the data which will be
;               written into the SST39VF016.
;       es:di   DESTINATION address which will be written with the
;               data passed in for ds:si
;
; Output:
;       None
;       SI, DI  Contain 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
                                ; auto-increment SI and DI
;
; Erase the block before programming.  Each erase command will erase a total
; of 64K bytes of the SST39VF016.
;
        call    Erase_One_Block
;
; The following loop will program a total of 64K bytes to SST's SST39VF016
;
        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
        loop    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
;
; 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

        mov     al, es:[di]     ; read a byte form 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 registers

        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
;       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 word 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

⌨️ 快捷键说明

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