?? sst39vf016.txt
字號(hào):
Software
Drivers
39VF016
16 Mbit Multi-Purpose Flash
September 2001
ABOUT THE SOFTWARE
This application note provides software driver examples for 39VF016,
16 Mbit Multi-Purpose Flash, that can be used in any microprocessor based
system. Software driver examples used in this document utilize two programming
languages: (a) high -level "C" for broad platform support and (b) optimized x86
assembly language. In many cases, software driver routines can be inserted
"as is" into the main body of code being developed by the system software
developers. Extensive comments are included in each routine to describe the
function of each routine. The driver in "C" language can be used with many
microprocessors and microcontrollers, while the x86 assembly language provides
an optimized solution for x86 microprocessors. Note: A Code Segment base
address equal to C000h was used in this sample code. Software designers shall
assign the segment address appropriate to their designs.
ABOUT THE 39VF016
Companion product datasheets for the 39VF016 should be reviewed in
conjunction with this application note for a complete understanding of
the device.
Both the C and x86 assembly code in the document contain the following routines,
in this order:
Name Function
------------------------------------------------------------------
Check_SST_39VF016 Check manufacturer and device ID
CFI_Query CFI Query Entry/Exit command sequence
Erase_One_Sector Erase a sector of 4096 bytes
Erase_One_Block Erase a block of 64K bytes
Erase_Entire_Chip Erase the contents of the entire chip
Program_One_Byte Alter data in one byte
Program_One_Sector Alter data in 4096 bytes sector
Program_One_Block Alter data in 64K bytes block
Check_Toggle_Ready End of internal program or erase detection using
Toggle bit
Check_Data_Polling End of internal program or erase detection using
Data# polling
"C" LANGUAGE DRIVERS
/***********************************************************************/
/* Copyright Silicon Storage Technology, Inc. (SST), 1994-2001 */
/* Example "C" language Driver of 39VF016 16 Mbit Multi-Purpose Flash */
/* Nelson Wang, Silicon Storage Technology, Inc. */
/* */
/* Revision 1.0, Sept. 12, 2001 */
/* */
/* This file requires these external "timing" routines: */
/* */
/* 1.) Delay_150_Nano_Seconds */
/* 2.) Delay_25_Milli_Seconds */
/* 3.) Delay_100_Milli_Seconds */
/***********************************************************************/
#define FALSE 0
#define TRUE 1
#define SECTOR_SIZE 4096 /* Must be 4096 bytes for 39VF016 */
#define BLOCK_SIZE 65536 /* Must be 64K bytes for 39VF016 */
#define SST_ID 0xBF /* SST Manufacturer's ID code */
#define SST_39VF016 0xD9 /* SST39VF016 device code */
typedef unsigned char BYTE;
typedef unsigned int WORD;
/* -------------------------------------------------------------------- */
/* EXTERNAL ROUTINES */
/* -------------------------------------------------------------------- */
extern void Delay_150_Nano_Seconds();
extern void Delay_25_Milli_Seconds();
extern void Delay_100_Milli_Seconds();
/************************************************************************/
/* PROCEDURE: Check_SST_39VF016 */
/* */
/* This procedure decides whether a physical hardware device has a */
/* SST39VF016 16 Mbit Multi-Purpose Flash installed or not. */
/* */
/* Input: */
/* None */
/* */
/* Output: */
/* return TRUE: indicates a SST39VF016 */
/* return FALSE: indicates not a SST39VF016 */
/************************************************************************/
int Check_SST_39VF016()
{
BYTE far *Temp;
BYTE SST_id1;
BYTE SST_id2;
int ReturnStatus;
/* Issue the Software Product ID code to 39VF016 */
Temp = (BYTE far *)0xC0005555; /* set up address to be C000:5555h */
*Temp = 0xAA; /* write data 0xAA to the address */
Temp = (BYTE far *)0xC0002AAA; /* set up address to be C000:2AAAh */
*Temp = 0x55; /* write data 0x55 to the address */
Temp = (BYTE far *)0xC0005555; /* set up address to be C000:5555h */
*Temp = 0x90; /* write data 0x90 to the address */
Delay_150_Nano_Seconds(); /* check DATABOOK for the most */
/* accurate value -- Tida */
/* Read the product ID from 39VF016 */
Temp = (BYTE far *)0xC0000000; /* set up address to be C000:0000h */
SST_id1 = *Temp; /* get first ID byte */
Temp = (BYTE far *)0xC0000001;/* set up address to be C000:0001h */
SST_id2 = *Temp; /* get first ID byte */
/* Determine whether there is a SST 39VF016 installed or not */
if ((SST_id1 == SST_ID) && (SST_id2 ==SST_39VF016))
ReturnStatus = TRUE;
else
ReturnStatus = FALSE;
/* Issue the Soffware Product ID Exit code thus returning the 39VF016*/
/* to the read operating mode */
Temp = (BYTE far *)0xC0005555; /* set up address to be C000:5555h */
*Temp = 0xAA; /* write data 0xAA to the address */
Temp = (BYTE far *)0xC0002AAA; /* set up address to be C000:2AAAh */
*Temp = 0x55; /* write data 0x55 to the address */
Temp = (BYTE far *)0xC0005555; /* set up address to be C000:5555h */
*Temp =0xF0; /* write data 0xF0 to the address */
Delay_150_Nano_Seconds(); /* check DATABOOK for the most */
/* accurate value -- Tida */
return(ReturnStatus);
}
/************************************************************************/
/* PROCEDURE: CFI_Query */
/* */
/* This procedure should be used to query for CFI information */
/* */
/* Input: */
/* None */
/* */
/* Output: */
/* None */
/************************************************************************/
int CFI_Query()
{
BYTE far *Temp1;
/* Issue the Software Product ID code to 39VF016 */
Temp1 = (BYTE far *)0xC0005555; /* set up address to be C000:5555h */
*Temp1= 0xAA; /* write data 0xAA to the address */
Temp1 = (BYTE far *)0xC0002AAA; /* set up address to be C000:2AAAh */
*Temp1= 0x55; /* write data 0x55 to the address */
Temp1 = (BYTE far *)0xC0005555; /* set up address to be C000:5555h */
*Temp1= 0x98; /* write data 0x98 to the address */
Delay_150_Nano_Seconds();
/* --------------------------------- */
/* Perform all CFI operations here */
/* NOTE: no sample code provided */
/* --------------------------------- */
/* Issue the CFI Exit code thus returning the 39VF016 */
/* to the read operating mode */
Temp1 = (BYTE far *)0xC0005555; /* set up address to be C000:5555h */
*Temp1 = 0xAA; /* write data 0xAA to the address */
Temp1 = (BYTE far *)0xC0002AAA; /* set up address to be C000:2AAAh */
*Temp1 = 0x55; /* write data 0x55 to the address */
Temp1 = (BYTE far *)0xC0005555; /* set up address to be C000:5555h */
*Temp1 = 0xF0; /* write data 0xF0 to the address */
Delay_150_Nano_Seconds();
}
/************************************************************************/
/* PROCEDURE: Erase_One_Sector */
/* */
/* This procedure can be used to erase a total of 4096 bytes. */
/* */
/* Input: */
/* Dst DESTINATION address where the erase operation starts */
/* */
/* Output: */
/* NONE */
/************************************************************************/
int Erase_One_Sector (BYTE far *Dst)
{
BYTE far *Temp;
/* Issue the Sector Erase command to 39VF016 */
Temp = (BYTE far *)0xC0005555; /* set up address to be C000:5555h */
*Temp = 0xAA; /* write data 0xAA to the address */
Temp = (BYTE far *)0xC0002AAA; /* set up address to be C000:2AAAh */
*Temp = 0x55; /* write data 0x55 to the address */
Temp = (BYTE far *)0xC0005555; /* set up address to be C000:5555h */
*Temp = 0x80; /* write data 0x80 to the address */
Temp = (BYTE far *)0xC0005555; /* set up address to be C000:5555h */
*Temp = 0xAA; /* write data 0xAA to the address */
Temp = (BYTE far *)0xC0002AAA; /* set up address to be C000:2AAAh */
*Temp = 0x55; /* write data 0x55 to the address */
Temp = Dst; /* set up starting address to be erased */
*Temp = 0x30; /* write data 0x30 to the address */
Delay_25_Milli_Seconds(); /* Delay time = Tse */
}
/************************************************************************/
/* PROCEDURE: Erase_One_Block */
/* */
/* This procedure can be used to erase a total of 64K bytes. */
/* */
/* Input: */
/* Dst DESTINATION address where the erase operation starts */
/* */
/* Output: */
/* NONE */
/************************************************************************/
int Erase_One_Block (BYTE far *Dst)
{
BYTE far *Temp;
/* Issue the Sector Erase command to 39VF016 */
Temp = (BYTE far *)0xC0005555; /* set up address to be C000:5555h */
*Temp = 0xAA; /* write data 0xAA to the address */
Temp = (BYTE far *)0xC0002AAA; /* set up address to be C000:2AAAh */
*Temp = 0x55; /* write data 0x55 to the address */
Temp = (BYTE far *)0xC0005555; /* set up address to be C000:5555h */
*Temp = 0x80; /* write data 0x80 to the address */
Temp = (BYTE far *)0xC0005555; /* set up address to be C000:5555h */
*Temp = 0xAA; /* write data 0xAA to the address */
Temp = (BYTE far *)0xC0002AAA; /* set up address to be C000:2AAAh */
*Temp = 0x55; /* write data 0x55 to the address */
Temp = Dst; /* set up starting address to be erased */
*Temp = 0x50; /* write data 0x50 to the address */
Delay_25_Milli_Seconds(); /* Delay time = Tbe */
}
/************************************************************************/
/* PROCEDURE: Erase_Entire_Chip */
/* */
/* This procedure can be used to erase the entire chip. */
/* */
/* Input: */
/* NONE */
/* */
/* Output: */
/* NONE */
/************************************************************************/
int Erase_Entire_Chip()
{
BYTE far *Temp;
/* Issue the Chip Erase command to 39VF016 */
Temp = (BYTE far *)0xC0005555; /* set up address to be C000:5555h */
*Temp = 0xAA; /* write data 0xAA to the address */
Temp = (BYTE far *)0xC0002AAA; /* set up address to be C000:2AAAh */
*Temp = 0x55; /* write data 0x55 to the address */
Temp = (BYTE far *)0xC0005555; /* set up address to be C000:5555h */
*Temp = 0x80; /* write data 0x80 to the address */
Temp = (BYTE far *)0xC0005555; /* set up address to be C000:5555h */
*Temp = 0xAA; /* write data 0xAA to the address */
Temp = (BYTE far *)0xC0002AAA; /* set up address to be C000:2AAAh */
*Temp = 0x55; /* write data 0x55 to the address */
Temp = (BYTE far *)0xC0005555; /* set up address to be C000:5555h */
*Temp = 0x10; /* write data 0x10 to the address */
Delay_100_Milli_Seconds(); /* Delay Tsce time */
}
/************************************************************************/
/* PROCEDURE: Program_One_Byte */
/* */
/* This procedure can be used to program ONE byte of data to the */
/* 39VF016. */
/* */
/* NOTE: It is necessary to first erase the sector containing the */
/* byte to be programmed. */
/* */
/* Input: */
/* Src The BYTE which will be written to the 39VF016 */
/* Dst DESTINATION address which will be written with the */
/* data passed in from Src */
/* */
/* Output: */
/* None */
/************************************************************************/
void Program_One_Byte (BYTE SrcByte, BYTE far *Dst)
{
BYTE far *Temp;
BYTE far *SourceBuf;
BYTE far *DestBuf;
int Index;
DestBuf = Dst;
Temp = (BYTE far *)0xC0005555; /* set up address to be C000:555h */
*Temp = 0xAA; /* write data 0xAA to the address */
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -