Until recently, the most flexible external
boot memory was an EPROM. However, if you
needed to erase or update the data on an EPROM,
you had to remove it from the system, expose it to
ultraviolet light, place it in an EPROM burner,
and then insert it back into the design. A better
solution is to update code/data while the nonvolatile memory is still in the system. This is
particularly true in modem designs, where
communications protocols are continuously
updated, and in systems such as a digital
answering machine, where you must save
compressed voice/data in a simple and efficient
fashion. With the advent of FLASH memories, it
is possible to save data permanently and update it
when necessary without removing the IC. FLASH
memories are also an asset in systems that need
to save data during a power outage or brownout.
The DSP can store its code/data contents from
volatile internal memory to an external, nonvolatile memory, and on revival of the system,
rewrite the old information back to the DSP.
This Engineering Note demonstrates how
to interface a 5v FLASH memory to an ADSP218x DSP. The supplied code shows you how to
program, erase, and retrieve device ID
information from several AMD FLASH devices.
BDMA Wiring:
A0-A13A0-A13
D16-D23A14-A21
D8-D15D0-D7
BMSCE
WRWE
RDOE
Figure 1. DSP -> FLASH Wiring
During read operations, the DSP sees the
FLASH as an EPROM. The only additional signal
necessary for FLASH systems is the WR signal that
is used when changing the contents of the FLASH..
Basic AMD FLASH Operation:
The AMD FLASH memory space is parsed
into a series of sectors. You can set each sector so
it is readable, but not erasable. These boundaries
are invisible; it is possible to read/write seamlessly
across sector boundaries. The sector protection
feature is particularly helpful in systems where the
DSP is booting from and writing to a FLASH. It can
protect boot sectors and leave the remaining
portions of memory unprotected.
The AMD FLASH uses a byte-by-byte
programming protocol. A series of command words
are written to the FLASH (using BDMA writes in this
example), essentially “unlocking” the device so the
proper information can be written or obtained. The
following operations, called Embedded
Programming Algorithms, can be performed on an
AMD FLASH:
Autoselect:
This operation identifies the manufacturer,
model number, and the protection status of
any sector.
The BDMA port allows for “glueless”
connections between the DSP and a FLASH. Table
1 shows the wiring between the DSP and a FLASH.
Byte Write:
Use this operation programs a single byte of
data into an unprotected FLASH sector.
Sector Erase:
a
This operation erases a sector of
unprotected memory.
BDMA_BWCOUNT:
Chip Erase:
This operation erases all unprotected
sectors on a FLASH.
The particular FLASH determines the exact
series of signals that must be sent from the DSP to
perform each embedded programming algorithm.
Please refer to the appropriate AMD Data Sheet for
more memory programming information.
Flash Programming via the BDMA Port:
The ADSP-218x has an external memory
port (BDMA port) that you can use for off-chip reads
and writes of a byte-wide device. The data transfers
are initiated by setting four system control registers:
the BDMA Internal Address Register (BDMA_BIAD),
the BDMA External Address Register
(BDMA_BEAD), the BDMA Control Register
(BDMA_BDMA_CTRL) and the BDMA Word Count
Register (BDMA_BWCOUNT). These registers are
explained below (for more information, please refer
to Chapter 11 in the ADSP-2100 Family User’s
Manual):
BDMA_BIAD:
This register sets the number of BDMA
transfers that are completed. This number refers to
the number of BDMA words that are sent, not the
number of bytes that are transferred from the
external memory (for example, to transfer 16 data
memory words to external memory, set
BDMA_BWCOUNT to 16, not 32). The BDMA
transfers are initiated immediately after this register
is set and a BDMA interrupt is generated once
BDMA_BWCOUNT is equal to zero. It is also
possible to poll the BDMA_BWCOUNT register to
see if the BDMA transfer was completed (this is
useful if the processor cannot service a BDMA at
that time).
BDMA Wait State Generation:
You set the number of wait states for BDMA
transfers in the memory-mapped control register
PF_CSC (DM(0x3FE6)), at bit locations 12, 13 and
14. When the DSP is rebooted, the number of wait
states is automatically set to seven. When setting
the wait state register, you must consider the rise/fall
times for every I/O line. Generosity in calculating
wait states will help guarantee that your system
works under greater bus loads.
On data reads, this register contains the
address where data is saved in internal memory. On
data writes, it contains the address of the first byte
that is transferred into the FLASH.
BDMA_BEAD:
On data reads, this register contains the
lower fourteen bits of the address where data is read
from and transferred into internal memory. On data
writes, this register contains the lower fourteen bits
of the external memories’ starting transfer address.
BDMA_BDMA_CTRL:
This register contains four pieces of
information. It contains the upper eight bits of the
external address where data is stored to or read
from. This register also contains a bit that
determines if the DSP automatically reboots once a
BDMA transfer is complete. There is a two bit data
field that determines the configuration of byte
memory storage (8 LSB, 8 MSB, 16 (LSB then MSB)
or 24 bit packets). Lastly, there is a one bit switch
that determines if the BDMA transfer is an external
read or write.
Flash Server Software:
Attached to this paper are a number of
software modules used for accessing and controlling
the AMD29LV010, AMD29LV020, AMD20LV040,
and AMD29F040 FLASH memories. This software
offers five .ENTRY points in the server code that are
function names for FLASH operations. These
functions are listed and described below:
bdma_setup:
This function sets the number of wait states
and sets the appropriate interrupts.
prog_byte:
This function unlocks and writes the value of
d_byte into the FLASH.
read_byte:
This function reads back the appropriate
byte from the FLASH.
sect_erase:
This function erases one sector of the
FLASH.
EE-39Page 2
Notes on using Analog Devices’ DSP, audio, & video components from the Computer Products Division
This function increments the external
address to the FLASH.
More information on each of these functions,
including the parameters that are passed into each
subroutine is included in the comments of the
supplied code.
information while maintaining acceptable edge
characteristics. On some systems, the RC circuit is
not necessary to ensure that the transfers are
completed properly (the bus capacitance is enough
to hold the data lines high). For a complete list of
the revisions of the DSP with this exception, please
see the appropriate Anomalies and Workarounds
document, available from Analog Devices.
To access the FLASH server code, it must
first be assembled and linked into your existing
software. In order to make the server code “visible”
to pre-existing code in other modules, the
subroutines that will be used must be declared as
external functions. After the module flash_srv
(listing 1), a small example program is given (listings
2-4), showing how to implement the FLASH
programming software. For more information on
linking and calling functions located in separate
modules, please refer to the ADSP-2100 FamilyAssembler Tools and Simulator Manual.
FLASH System Caveats:
The BDMA Write Anomaly:
On some revisions of the ADSP-218x, there
is anomalous behavior on the data lines during
BDMA writes. This exception is characterized as a
two volt negative glitch (width 3ns) on each of the
data lines. This glitch appears at the beginning of
each wait state and is independent of the input
voltage. Therefore, the outputs are briefly driven to
3v on a 5v DSP and 1.3v on a 3.3v DSP.
You can counter the anomaly on a 5v DSP
with a simple RC network (see Figure 1) attached to
each of the data pins and to ground (R=120Ω,
C=47pF) that filters out the unwanted high frequency
inputoutput
GND
Figure 1. RC circuit configuration
Byte Programming:
You cannot correctly program a byte of data
unless the contents of that register first equal 0xFF.
Essentially, a byte program only converts a logic ‘1’
to a logic ‘0’. A sector or chip erase operation is the
only operation that converts a logic ‘0’ to a logic ‘1’ .
Additional Information:
For more information about interfacing
ADSP-218x DSPs to various FLASHes, please
consult the following sources:
ADSP-2100 Family User’s Manual
ADSP-2100 Family Assembler Tools and Simulator
Manual
http://www.analog.com
http://www.amd.com
EE-39Page 3
Notes on using Analog Devices’ DSP, audio, & video components from the Computer Products Division
{ Follwing four constants are the requirements for the FLASH memory and are
preset for AMD 8bit wide flash memories requiring either 16bit or 12bit
address unlock sequences. Possible types would be i.e. AM29LV001, AM29LV002,
AM29F004, AM29LV004.
To adapt the given FLASH server to a different FLASH EPROM vendor, please
check whether the programming sequence can be used and change the following
four constants accordingly.
The word ulock1_a decribes the 14bit address range for the BEAD register,
while ulock1_c must be put into BDMAC, containing the upper 8 page bits
shifted 8bits left and ORed with 0x7 command bits to perform the BDMA write.
i.e.: the first bus cycle is address 0x5555 and 0xAA as data
}
.const ulock1_a=0x1555;{ lower 14bit part of address }
.const ulock1_c=0x0107;{ upper 8bit part of address }
.const ulock1_b=0x00AA;{ byte used in unlock }
{ The word ulock2_a decribes the 14bit address range for the BEAD register,
while ulock2_c must be put into BDMAC, containing the upper 8 page bits
shifted 8bits left and ORed with 0x7 command bits to perform the BDMA write.
i.e.: the second bus cycle is address 0x2AAA and 0x55 as data
}
.const ulock2_a=0x2AAA;{ lower 14bit part of address }
.const ulock2_c=0x0007;{ upper 8bit part of address }
.const ulock2_b=0x0055;{ byte used in unlock }
{ ADSP-218x specific registers, please do not change
}
.const BDMA_BIAD= 0x3fe1;
.const BDMA_BEAD= 0x3fe2;
.const BDMA_BDMA_Ctrl= 0x3fe3;
.const BDMA_BWCOUNT= 0x3fe4;
.const PFTYPE= 0x3fe6;
.var/dm/ramd_byte;{ holds value read / written }
.globald_byte;
.var/dm/ramd_btmp;{ temporaray value read / written }