![](http://datasheet.mmic.net.cn/290000/22363A_datasheet_16110319/22363A_9.png)
8
Simple System Interface for UltraNAND Flash
Pseudo Code Example
Included below is an example of how the Interface PLD can be used to allow the system software to control all op-
erations that UltraNAND supports. In this example, one 528 byte page of information will be input to one device and
then programmed. The following system configuration is assumed:
1. SOURCE – This is a 528 byte source buffer in system memory
2. DEST – This is the target page to be programmed in UltraNAND
3. PORTADDR – This is a system generated I/O mapped port address for the UltraNAND device to occupy
INIT:
SOURCE ADDRESS POINTER
DEST ADDRESS POINTER
;Set up the address for the 528 byte source system page
;Set up the address for the 528 byte target page in Flash
START:
Write 00h to (PORTADDR + 8)
Write 00h to (PORTADDR + 3)
Write FFh to (PORTADDR + 1)
Write 00h to (PORTADDR + 1)
;Set OUTCE0# (low) to enable UltraNAND. Data is a don’t care
;Clear ALE (low) prior to issuing command. Data is a don’t care
;Send a reset command to reset the Flash (may be omitted)
;Send a “Read First Half Page” command to the Flash to set
;the internal pointer to the first half page region in the Flash
;Set SE# (low) to allow Spare Area access. Data is a don’t care
;Clear WP# (high) to allow Flash program. Data is a don’t care
;Send an “Input Data” command to the Flash
;Set ALE (high) prior to issuing addresses. Data is a don’t care
;Load the first address byte into the Flash
;Load the second address byte into the Flash
;Load the third address byte into the Flash
;Clear ALE (low) prior to writing data. Data is a don’t care
Write 00h to (PORTADDR + 4)
Write 00h to (PORTADDR + 7)
Write 80h to (PORTADDR + 1)
Write 00h to (PORTADDR + 2)
Write DEST[A7-A0] to (PORTADDR + 0)
Write DEST[A16-A9] to (PORTADDR + 0)
Write DEST[A24-A17] to (PORTADDR + 0)
Write 00h to (PORTADDR + 3)
LOOP1:
;This is where we fill the Flash buffer
;Write the data contents at the SOURCE location to the data port
;Has the last data byte been written
;If the last byte is loaded go ahead and program the Flash
;If not point to the next address location and write another byte
Write [SOURCE] to (PORTADDR + 0)
Does SOURCE = 527
IF YES branch to PROG:
SOURCE = SOURCE + 1
Branch to LOOP1:
PROG:
;All 528 bytes are loaded so program the Flash
;Send a “Page Program” command to the Flash
;Send a “Read Status” command to the Flash
Write 10h to (PORTADDR + 1)
Write 70h to (PORTADDR + 1)
CHKSTAT:
Read from (PORTADDR + 0)
Does D6 = 1
IF YES branch to DONE:
Branch to CHKSTAT:
;Read the device status to see if the program is done
;Check to see if the device is ready
;If the program operation is done go and check for pass/fail
;If not continue to check the status for a ready condition
DONE:
Write 00h to (PORTADDR + 6)
Read from (PORTADDR + 0)
Does D0 = 1
IF YES branch to FAIL:
Write 00h to (PORTADDR + 9)
Return (program successful)
;Set WP# (low) to re-protect the Flash. Data is a don’t care
;Read the device status again to see if the program passed
;Check to see if the program operation passed or failed
;A “1” in the D0 location indicates a failure condition
;Clear OUTCE0# (high) to disable UltraNAND. Data is a don’t care
;The program operation passed so return and report
FAIL:
Write 00h to (PORTADDR + 9)
Return (program failed)
;Clear OUTCE0# (high) to disable UltraNAND. Data is a don’t care
;The program operation failed so return and report