?? clr_alg.asm
字號(hào):
; Next, the following steps are performed
; 1. DATA is set to 0000h for use in the compare stage, since in clear the flash is set to all
; words = 0000h.
; 2. Calls the Level 2 routine CLR_LOOP to clear the sector user space.
; 3. Calls the Level 2 routine CLR_LOOP to clear the sector base space.
; This clears out any bits in the base sector space that were not mapped into the user space.
; 4. It then calls the Level2 routine CLR_LOOP to clear the redundant
; row bits, that were not mapped into the user space.
;--------------------------------------------------------------------------------------------------
SPLK #0000h,flashAlgoVars.DATA ;Load 0000h for compare.
SPLK #0000h,flashAlgoVars.FL_CMD ;Setup the routine to address the base space.
SPLK #0001H,flashAlgoVars.FAIL_CMD ;Setup the routine to fail if any bits in
;the user space fail to clear.
CALL CLR_LOOP ;Call the CLR_Loop routine to clear
;the user space.
;--------------------------------------------------------------------------------------------------
.if (DEV_TYPE = LF2407) ; If the setting is the LF2407 then
LACC flashAlgoVars.SECTOR_KEY ;Get the sector key.
AND #0006H ;Mask out bits for sectors 0 and 3.
BCND NO_RED_CLEAR,EQ ;Perform NOROWRED and PRECON steps only
;for sectors 1 and 2.
.endif
;--------------------------------------------------------------------------------------------------
SPLK #0080h,flashAlgoVars.FL_CMD ;Setup the NOROWRED mode.
SPLK #0000H,flashAlgoVars.FAIL_CMD ;Set up the routine to ingnore failure of
;bits to program on MX_PCNT pulses.
CALL CLR_LOOP ;Clear the base sector space (NOROWRED)
SPLK #0100h,flashAlgoVars.FL_CMD ;Setup the redundancy precondition mode.
SPLK #0000H,flashAlgoVars.FAIL_CMD ;Set up the routine to ingnore failure of
;bits to program on MX_PCNT pulses.
CALL CLR_LOOP ;Call the CLR_Loop routine to clear
;the redundant bits.
;--------------------------------------------------------------------------------------------------
NO_RED_CLEAR:
CALL END1
RET
;--------------------------------------------------------------------------------------------------
; CLR_LOOP:
;--------------------------------------------------------------------------------------------------
; This function is desginated as a LEVEL_3 subroutine.
;--------------------------------------------------------------------------------------------------
; This function is the implementation for the clear loop. It reads the flash one word at a
; time in PROGVER mode. It then compares this word to the word in DATA. In case of the this
; algo, it is always 0000h. If then goes processes the next word if it is already zero,
; else it enters BITMASK to form the bitmask for applying programming pulses to the Flash array.
;--------------------------------------------------------------------------------------------------
CLR_LOOP:
SPLK #MX_PCNT,flashAlgoVars.PLS_CNT ;Initialize the program pulse count.
BLDD #flashAlgoVars.FL_SECST,flashAlgoVars.ADDR
;Initialize the address counter.
PGVERON:
LACC #WADDR ;Load the WADDR Register with the address of
CALL SETWADDR ;the word to be programmed.
LACC flashAlgoVars.FL_CMD
XOR #0004h ;(PROGVER Command)Program Verification Command.
SACL flashAlgoVars.PAD
LACC #CTRL ;Enter the PROGVER mode.
TBLW flashAlgoVars.PAD
LACC #PMPC
SPLK #0005h,flashAlgoVars.PAD
TBLW flashAlgoVars.PAD ;Activate the PGVER Mode by writing to
;PMPC.
SDELAY #T_pva_e ;Wait T_pva(E)
CALL READWORD
PGVEROFF:
SPLK #0000h,flashAlgoVars.PAD1 ;Clear out PMPC.
CALL CLRCMD ;
SDELAY #Tpv_h_P ; Wait for Program verify hold time
SPLK #0001h,flashAlgoVars.PAD1 ;Clear out PMPC and CTRL
CALL CLRCMD ;Since PMPC is cleared already, it is unchanged.
SDELAY #Tpv_h_C ;Hold the normal read mode.
COMPARE:
LACC flashAlgoVars.READ ;Get the value of the word read out during
;Program Verify.
OR #0000h ;OR this value with 0000h
BCND NEXTWORD,EQ ;If == 0000h then this word (*ADDR) is
;programmed, process the next word.
;--------------------------------------------------------------------------------------------------
; BITMASK:
; This section forms the bitmask to write to the WDATA register.
; READ contains the value read during program verify above,
; and this is used to build the mask.
; Once the mask is built, the sub-routine PROG is called.
;--------------------------------------------------------------------------------------------------
; Notes on building the mask:
;
; ** IMPORTANT: This mask building assumes processing is always to clear the
; ** flash, i.e. the end value in the flash is assumed to be 0000h.
; **
;
; This works as follows:
; 1. Get the value read out during program verify.
; 2. Any bits that are 0s should not get any more pulses. While any bits that are 1s
; should get pulses.
; 3. To apply pulses bits in the WDATA register should be 0s.
; 4. XOR the read value with 0ffffh. This inverts all bits in the read value. So bits that
; are 0s send 1s in the corresponding bits in WDATA and bits that are 1s send 0s in the
; corresponding bits in WDATA.
; 5. This ensures that prog applied pulses to those bits read out as 1s.
;--------------------------------------------------------------------------------------------------
LACC flashAlgoVars.READ ;Get the value read during program verify
XOR #0ffffh ;Acc has the bits now to be written to WDATA.
SACL flashAlgoVars.DATA,0 ;Store acc in flashAlgoVars.DATA
CALL PROG ;Call the PROGRAM routine, that applies the
;pulses.
;--------------------------------------------------------------------------------------------------
; PGCNT: Program Pulse Count Advance / Check:
; 1. Advance the pulse counter.
; 2. Check the pulse counter to see if this has exceeded limits.
; 3. Error handling if (2) is true.
;--------------------------------------------------------------------------------------------------
PGCNT: LACC flashAlgoVars.PLS_CNT ;Decrement the pulse counter
SUB #1 ;
SACL flashAlgoVars.PLS_CNT ;Pulse counter now has remaining
;pulses allowable.
BCND CHK_IF_FAIL,EQ ;If zero then the pulse count is exceeded,
;enter error handling,
B PGVERON ;verify word programmed
;--------------------------------------------------------------------------------------------------
CHK_IF_FAIL: ; If here then MAX_PCNT pulses have been
; applied. So, check the fail command.
LACL flashAlgoVars.FAIL_CMD ; Get the FAIL_CMD passed from caller.
BCND ERROR,NEQ ; If non-zero begin error handling.
B NEXTWORD ; If fail command is zero, then the
; caller intended to allow programming
; failures. So continue the flow.
ERROR: CALL END1
B ERROR1
;--------------------------------------------------------------------------------------------------
; NEXTWORD
; This block does the following things:
; 1. Checks if the ADDR is at the last address in the sector.
; 2. If not, increments ADDR.
; 3. Sets up program pulse count for programming the next word.
;--------------------------------------------------------------------------------------------------
NEXTWORD:
LACL flashAlgoVars.ADDR ;ACC = (address of previous word programmed).
SUB flashAlgoVars.FL_SECEND ;ACC = (prev word addr) - (last address of sector)
BCND NW,NEQ ;If there is a match end the routine,
RET ;otherwise continue with the next word.
NW LACL flashAlgoVars.ADDR ;ACC = (address of previous word programmed).
ADD #1 ;INCREMENT ADDR
SACL flashAlgoVars.ADDR ;STORE ADDR OF NEXT WORD
SPLK #MX_PCNT,flashAlgoVars.PLS_CNT ;Initialize PROGRAM PULSE COUNT
B PGVERON ;begin prog of next word
;--------------------------------------------------------------------------------------------------
; PROG: Program subroutine.
;--------------------------------------------------------------------------------------------------
; This is a LEVEL4 subroutine.
;--------------------------------------------------------------------------------------------------
;
; 1. This subroutine applies programming pulses to the flash word based on
; the bitmask built by the caller and placed in flashAlgoVars.DATA.
;
; 2. The pulses are applied to the main array or the redundant rows depending
; on the status of flashAlgoVars.FL_CMD.
; FL_CMD = 0080h (NOROWRED) programs the bits in the main array.
; FL_CMD = 0100h (PRECON).
;--------------------------------------------------------------------------------------------------
PROG LACC #WDATA ;Load data to be prog
TBLW flashAlgoVars.DATA ;Write data to the WDATA register.
LACC flashAlgoVars.FL_CMD ;Get the flash command.
XOR #0003h ;Add in the bits for the PROG mode.
SACL flashAlgoVars.PAD
LACC #CTRL ;Init prog mode
TBLW flashAlgoVars.PAD
SDELAY #T_psu_p ;Wait T_psu(P)
LACC #PMPC ;Turn on prog voltages
SPLK #0005h,flashAlgoVars.PAD
TBLW flashAlgoVars.PAD
PPW SDELAY #T_prog_e1 ;PROG pulse width part 1
SDELAY #T_prog_e2 ;PROG pulse width part 2
SPLK #0000h,flashAlgoVars.PAD ;Turn off PROG Voltages.
TBLW flashAlgoVars.PAD
SDELAY #Tph_P ;Wait T_ph(P) (HOLD TIME).
SPLK #0001h,flashAlgoVars.PAD1 ;Clear PMPC and CTRL.
CALL CLRCMD ;Since PMPC is 0s already from above,
;really the only thing affected is CTRL
SDELAY #Tph_A ;Wait in normal read mode.
RET
;--------------------------------------------------------------------------------------------------
; READWORD
; This routine performs the following operations
; 1. Reads the word at the location pointed to by flashAlgoVars.ADDR.
; 2. Stores the word in the variable READ.
; 3. Returns to the caller in Register Mode.
; This is a LEVEL4 subroutine.
;--------------------------------------------------------------------------------------------------
READWORD:
ACCESS_ARRAY
LACC flashAlgoVars.ADDR ;Read word flash
TBLR flashAlgoVars.READ ;store word in READ (data space)
ACCESS_REGS
RET
;--------------------------------------------------------------------------------------------------
; END1:
; This routine performs the following operations
; 1. Clears the control registers PMPC,CNTL,WADDR,WDATA,ENABLE AND SECTOR)
; 2. Returns to the caller in ARRAY Mode.
;--------------------------------------------------------------------------------------------------
END1: SPLK #0006h,flashAlgoVars.PAD1 ;CLEAR ALL SIX
CALL CLRCMD
ACCESS_ARRAY
RET
;--------------------------------------------------------------------------------------------------
; CLRCMD
;--------------------------------------------------------------------------------------------------
; This routine performs the following operations
; 1. Places the flash in normal read mode by writing 0000 to two control
; registers PMPC=0000,CNTL=0000.
; 2. Returns to the caller in Register Mode.
;--------------------------------------------------------------------------------------------------
CLRCMD: ACCESS_REGS
SPLK #0,flashAlgoVars.PAD
LACC #0
RPT flashAlgoVars.PAD1
TBLW flashAlgoVars.PAD
RET
.label ClearAlgoEndMain
.sect "CSPL_text"
SETWADDR:
.label ClearAlgoStartSpl
TBLW flashAlgoVars.ADDR ;Perform the write to the address register.
RET
.label ClearAlgoEndSpl
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -