?? sst39vf200a.txt
字號:
Software
Drivers
39VF200A
2 Mbit Multi-Purpose Flash
September 2001
ABOUT THE SOFTWARE
This application note provides software driver examples for 39VF200A 2 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. 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 39VF200A
Companion product datasheet for the 39VF200A 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_39VF200 Check manufacturer and device ID
CFI_Query CFI Query Entry/Exit command sequence
Erase_One_Sector Erase a sector of 2048 words
Erase_One_Block Erase a block of 32K words
Erase_Entire_Chip Erase the contents of the entire chip
Program_One_Word Alter data in one word
Program_One_Sector Alter data in 2048 word sector
Program_One_Block Alter data in 32K word 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 39VF200A 2 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 2048 /* Must be 2048 words for 39VF200A */
#define BLOCK_SIZE 32768 /* Must be 32K words for 39VF200A */
#define SST_ID 0x00BF /* SST Manufacturer's ID code */
#define SST_39VF200 0x2789 /* SST39VF200A 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_39VF200 */
/* */
/* This procedure decides whether a physical hardware device has a */
/* SST39VF200A 2 Mbit Multi-Purpose Flash installed or not. */
/* */
/* Input: */
/* None */
/* */
/* Output: */
/* return TRUE: indicates a SST39VF200A */
/* return FALSE: indicates not a SST39VF200A */
/************************************************************************/
int Check_SST_39VF200()
{
WORD far *Temp;
WORD SST_id1;
WORD far *Temp1;
WORD SST_id2;
int ReturnStatus;
/* Issue the Software Product ID code to 39VF200A */
Temp1 = (WORD far *)0xC0005555; /* set up address to be C000:5555h */
*Temp1= 0xAAAA; /* write data 0xAAAA to the address */
Temp1 = (WORD far *)0xC0002AAA; /* set up address to be C000:2AAAh */
*Temp1= 0x5555; /* write data 0x5555 to the address */
Temp1 = (WORD far *)0xC0005555; /* set up address to be C000:5555h */
*Temp1= 0x9090; /* write data 0x9090 to the address */
Delay_150_Nano_Seconds(); /* insert delay time = Tida */
/* Read the product ID from 39VF200A */
Temp = (WORD far *)0xC0000000; /* set up address to be C000:0000h */
SST_id1 = *Temp; /* get first ID word */
SST_id1 = SST_id1 & 0xFF; /* mask off higher byte */
Temp1 = (WORD far *)0xC0000001; /* set up address to be C000:0001h */
SST_id2 = *Temp1; /* get second ID word */
/* Determine whether there is a SST39VF200A installed or not */
if ((SST_id1 == SST_ID) && (SST_id2 ==SST_39VF200))
ReturnStatus = TRUE;
else
ReturnStatus = FALSE;
/* Issue the SofTware Product ID Exit code thus returning the 39VF200A */
/* to the read operating mode */
Temp1 = (WORD far *)0xC0005555; /* set up address to be C000:5555h */
*Temp1 = 0xAAAA; /* write data 0xAAAA to the address */
Temp1 = (WORD far *)0xC0002AAA; /* set up address to be C000:2AAAh */
*Temp1 = 0x5555; /* write data 0x5555 to the address */
Temp1 = (WORD far *)0xC0005555; /* set up address to be C000:5555h */
*Temp1 = 0xF0F0; /* write data 0xF0F0 to the address */
Delay_150_Nano_Seconds(); /* insert delay time = Tida */
return(ReturnStatus);
}
/************************************************************************/
/* PROCEDURE: CFI_Query */
/* */
/* This procedure should be used to query for CFI information */
/* */
/* Input: */
/* None */
/* */
/* Output: */
/* None */
/************************************************************************/
int CFI_Query()
{
WORD far *Temp1;
/* Issue the Software Product ID code to 39VF200A */
Temp1 = (WORD far *)0xC0005555; /* set up address to be C000:5555h */
*Temp1= 0xAAAA; /* write data 0xAAAA to the address */
Temp1 = (WORD far *)0xC0002AAA; /* set up address to be C000:2AAAh */
*Temp1= 0x5555; /* write data 0x5555 to the address */
Temp1 = (WORD far *)0xC0005555; /* set up address to be C000:5555h */
*Temp1= 0x9898; /* write data 0x9898 to the address */
Delay_150_Nano_Seconds(); /* insert delay time = Tida */
/* --------------------------------- */
/* Perform all CFI operations here */
/* NOTE: no sample code provided */
/* --------------------------------- */
/* Issue the CFI Exit code thus returning the 39VF200A */
/* to the read operating mode */
Temp1 = (WORD far *)0xC0005555; /* set up address to be C000:5555h */
*Temp1 = 0xAAAA; /* write data 0xAAAA to the address */
Temp1 = (WORD far *)0xC0002AAA; /* set up address to be C000:2AAAh */
*Temp1 = 0x5555; /* write data 0x5555 to the address */
Temp1 = (WORD far *)0xC0005555; /* set up address to be C000:5555h */
*Temp1 = 0xF0F0; /* write data 0xF0F0 to the address */
Delay_150_Nano_Seconds(); /* insert delay time = Tida */
}
/************************************************************************/
/* PROCEDURE: Erase_One_Sector */
/* */
/* This procedure can be used to erase a total of 2048 words. */
/* */
/* Input: */
/* Dst DESTINATION address where the erase operation starts */
/* */
/* Output: */
/* NONE */
/************************************************************************/
int Erase_One_Sector (WORD far *Dst)
{
WORD far *Temp;
/* Issue the Sector Erase command to 39VF200A */
Temp = (WORD far *)0xC0005555; /* set up address to be C000:5555h */
*Temp = 0xAAAA; /* write data 0xAAAA to the address */
Temp = (WORD far *)0xC0002AAA; /* set up address to be C000:2AAAh */
*Temp = 0x5555; /* write data 0x5555 to the address */
Temp = (WORD far *)0xC0005555; /* set up address to be C000:5555h */
*Temp = 0x8080; /* write data 0x8080 to the address */
Temp = (WORD far *)0xC0005555; /* set up address to be C000:5555h */
*Temp = 0xAAAA; /* write data 0xAAAA to the address */
Temp = (WORD far *)0xC0002AAA; /* set up address to be C000:2AAAh */
*Temp = 0x5555; /* write data 0x5555 to the address */
Temp = Dst; /* set up starting address to be erased */
*Temp = 0x3030; /* write data 0x3030 to the address */
Delay_25_Milli_Seconds(); /* Delay time = Tse */
}
/************************************************************************/
/* PROCEDURE: Erase_One_Block */
/* */
/* This procedure can be used to erase a total of 32K words. */
/* */
/* Input: */
/* Dst DESTINATION address where the erase operation starts */
/* */
/* Output: */
/* NONE */
/************************************************************************/
int Erase_One_Block (WORD far *Dst)
{
WORD far *Temp;
/* Issue the Sector Erase command to 39VF200A */
Temp = (WORD far *)0xC0005555; /* set up address to be C000:5555h */
*Temp = 0xAAAA; /* write data 0xAAAA to the address */
Temp = (WORD far *)0xC0002AAA; /* set up address to be C000:2AAAh */
*Temp = 0x5555; /* write data 0x5555 to the address */
Temp = (WORD far *)0xC0005555; /* set up address to be C000:5555h */
*Temp = 0x8080; /* write data 0x8080 to the address */
Temp = (WORD far *)0xC0005555; /* set up address to be C000:5555h */
*Temp = 0xAAAA; /* write data 0xAAAA to the address */
Temp = (WORD far *)0xC0002AAA; /* set up address to be C000:2AAAh */
*Temp = 0x5555; /* write data 0x5555 to the address */
Temp = Dst; /* set up starting address to be erased */
*Temp = 0x5050; /* write data 0x5050 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()
{
WORD far *Temp;
/* Issue the Chip Erase command to 39VF200A */
Temp = (WORD far *)0xC0005555; /* set up address to be C000:5555h */
*Temp = 0xAAAA; /* write data 0xAAAA to the address */
Temp = (WORD far *)0xC0002AAA; /* set up address to be C000:2AAAh */
*Temp = 0x5555; /* write data 0x5555 to the address */
Temp = (WORD far *)0xC0005555; /* set up address to be C000:5555h */
*Temp = 0x8080; /* write data 0x8080 to the address */
Temp = (WORD far *)0xC0005555; /* set up address to be C000:5555h */
*Temp = 0xAAAA; /* write data 0xAAAA to the address */
Temp = (WORD far *)0xC0002AAA; /* set up address to be C000:2AAAh */
*Temp = 0x5555; /* write data 0x5555 to the address */
Temp = (WORD far *)0xC0005555; /* set up address to be C000:5555h */
*Temp = 0x1010; /* write data 0x1010 to the address */
Delay_100_Milli_Seconds(); /* Delay Tsce time */
}
/************************************************************************/
/* PROCEDURE: Program_One_Word */
/* */
/* This procedure can be used to program ONE word of data to the */
/* 39VF200A. */
/* */
/* NOTE: It is necessary to first erase the sector containing the */
/* word to be programmed. */
/* */
/* Input: */
/* Src The WORD which will be written to the 39VF200A */
/* Dst DESTINATION address which will be written with the */
/* data passed in from Src */
/* */
/* Output: */
/* None */
/************************************************************************/
void Program_One_Word (WORD SrcWord, WORD far *Dst)
{
WORD far *Temp;
WORD far *SourceBuf;
WORD far *DestBuf;
int Index;
DestBuf = Dst;
Temp = (WORD far *)0xC0005555; /* set up address to be C000:5555h */
*Temp = 0xAAAA; /* write data 0xAAAA to the address */
Temp = (WORD far *)0xC0002AAA; /* set up address to be C000:2AAAh */
*Temp = 0x5555; /* write data 0x5555 to the address */
Temp = (WORD far *)0xC0005555; /* set up address to be C000:5555h */
*Temp = 0xA0A0; /* write data 0xA0A0 to the address */
*DestBuf = SrcWord; /* transfer the byte to destination */
Check_Toggle_Ready(DestBuf); /* wait for TOGGLE bit to get ready */
}
/************************************************************************/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -