AP-377
INTRODUCTION
ABOUT THE CODE
This application note provides example software code
for word writing, block erasing, and otherwise control-
ling Intel’s 28F016SA, 28F016SV, 28F016XS and
28F016XD (hereafter referred to as 28F016SA) 16
Mbit symmetrically blocked memory components. Two
programming languages are provided: high-level ‘‘C’’
for broad platform support, and more optimized
ASM86 assembly. In many cases, the driver routines
can be inserted ‘‘as is’’ into the main body of code being
developed by the system software engineer. Extensive
comments are included in each routine to facilitate
adapting the code to specific applications.
The internal automation of the 28F016SA makes soft-
ware timing loops unnecessary and results in platform-
independent code. The following example code is de-
signed to be executed in any type of memory and with
all processor clock rates. C code can be used with many
microprocessors and microcontrollers, while ASM86
assembly code provides a solution optimized for Intel
microprocessors and embedded processors.
The 28F016SA, like the 28F008SA, is divided into 64
Kbyte blocks. Since the GSR and BSR are defined rela-
tive to the nearest preceding block beginning address, I
often refer to this ‘‘block base’’ address in the com-
ments.
Assumptions:
#Pointers (in C) or EDI offsets (in ASM86) are four
(4) bytes long, providing a flat addressing space over
the entire 28F016SA device. This implies the use of
386 or higher machines. If the code is to be run on a
machine with a smaller address space, the code must
be modified to include some sort of ‘‘windowing’’
scheme which maps segments of flash into system
memory. The Intel 82365 is commonly used for this
purpose.
#‘‘Ints’’ are 16 bit and ‘‘longs’’ 32 bit in C.
#It is assumed that these pointers return a value equal
to what they are pointing to. In other words, even
though the pointer may be four (4) bytes long, this
does not imply that incrementing the pointer by one
will move the pointer four (4) bytes in memory. It is
entirely dependent upon what the pointer is pointing
to that determines how the increment will be effect-
ed. In the case of four (4) byte pointers and 16-bit
ints, incrementing the pointer by one will effectively
move the pointer two (2) bytes.
#There exists a function ‘‘setÐpin’’ which can set an
individual 28F016SA pin, given the pin number.
#There exists a function ‘‘getÐpin’’ which can return
the value of an individual 28F016SA pin, given the
pin number.
#The C code can access a function which derives the
corresponding block base address from any given
address.
#BYTEÝpin on the device determines whether ad-
dressing refers to words or bytes. I assume word
writes/reads to a single device. With minor modifi-
cations this code can be adapted for a pair of
28F016SAs in Byte mode.
#28F016SA commands can be written to any address
in the block or device to be affected by that com-
mand.
Both the C and ASM86 code in this document contain
the following routines, in this order:
CSRÐwordÐbyteÐwrites(compatiblewith28F008SA)
CSRÐblockÐerase(compatible with 28F008SA)
CSRÐeraseÐsuspendÐtoÐread(compatible with
28F008SA)
lockÐblock
lockÐstatusÐuploadÐtoÐBSR
updateÐdataÐinÐaÐlockedÐblock
addÐdataÐinÐaÐlockedÐblock
ESRÐwordÐwrite
twoÐbyteÐwrite
ESRÐpageÐbufferÐwrite
ESRÐblockÐerase
ESRÐeraseÐallÐunlockedÐblocks
ESRÐsuspendÐtoÐreadÐarray
ESRÐautomaticÐeraseÐsuspendÐtoÐwrite
ESRÐfullÐstatusÐcheckÐforÐdataÐwrite
ESRÐfullÐstatusÐcheckÐforÐerase
singleÐloadÐtoÐpagebuffer
sequentialÐloadÐtoÐpagebuffer
uploadÐdeviceÐinformation
RYBYÐreconfiguration
pageÐbufferÐswap
The names of these routines have been changed to more
closely match the algorithms presented in the
28F016SA User’s Manual (Order Number 297372).
Please see Appendix A for a table documenting these
changes.
ABOUT THE 28F016SA
Companion product datasheets for the 28F016SA
should be reviewed in conjunction with this application
note for a complete understanding of the device.
The example code makes extensive use of bit-masking
when interpreting the status registers. As a quick re-
view, note that any bit in a register can be tested by
bitwise ANDing the register with the appropriate pow-
er of two. Since all of the bits other than the one being
1