Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Need help for.. Interfacing CFI FLASH with LPC 2478

Status
Not open for further replies.

SAKU

Newbie level 5
Joined
Jul 23, 2011
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,542
Hello,

I m trying to interface CFI flash SST39VF160 with LPC2478.

The Erase and Read works fine.. but the Write / Program function does not work..

Can any one please send me a sample code for the same...

Its urgent .. plz help... :!:


-SAK
 

Here's are driver routines written for an ARM, if I remember correctly, see attached file.
 

Attachments

  • SST_39VF160x_Driver_Example.txt
    33.8 KB · Views: 70
  • Like
Reactions: FvM and SAKU

    SAKU

    Points: 2
    Helpful Answer Positive Rating

    FvM

    Points: 2
    Helpful Answer Positive Rating
Sir,

I have used the same code and made modifications according to the requirement.
But it doesnt work for the WRITE() operations.

I'm sending you my code as an attachment.

I have added extra printf statements in the code to understand the flow of the code.

Could not attach the code in a txt file hence pastig it here..

-----------------------------------------------------------------------------
#include<lpc24xx.h>
#include"uart.h"
#include"sdram.h"


#define FALSE 0
#define TRUE 1

#define SECTOR_SIZE 2048 // Must be 2048 words for 39VF160X
#define BLOCK_SIZE 32768 // Must be 32K words for 39VF160X

#define SST_ID 0x00BF // SST Manufacturer's ID code
#define SST_39VF1601 0x234B // SST39VF1601 device code
#define SST_39VF1602 0x234A // SST39VF1602 device code

typedef unsigned char BYTE; // BYTE is 8-bit in length
typedef unsigned int WORD; // WORD is 16-bit in length
typedef unsigned long int Uint32; // Uint32 is 32-bit in length

Uint32 system_base = 0x81000000; // 4GByte System Memory Address.
// This sample code uses 0xC0000000 as the system_base address.
// The user should modify this address accordingly.

#define sysAddress(offset) ((volatile WORD *)(system_base + offset))

#define MAX_TIMEOUT 0x0000FFF // A ceiling constant used by Check_Toggle_
// Ready() and Check_Data_Polling().
// The user should modify this constant accordingly.


int Check_SST_39VF160X(void);
void CFI_Query(WORD*);
void SecID_Query(WORD*, WORD*);
int Erase_One_Sector(Uint32);
int Erase_One_Block (Uint32);
void Erase_Entire_Chip(void);
int Program_One_Word (WORD*, Uint32);
int Program_One_Sector (WORD*, Uint32);
int Program_One_Block (WORD *Src, Uint32 Dst);
int SecID_Lock_Status(void);
int User_SecID_Word_Program (WORD*, WORD*, int);
void User_SecID_Lock_Out (void);
void Erase_Suspend (void);
void Erase_Resume (void);
int Check_Toggle_Ready (Uint32);
int Check_Data_Polling (Uint32, WORD);

void Read(WORD *loc, WORD Numbyte );

// function
void Delay(unsigned int n)
{int i; //wait(1000000); gives a wait of 210ms
for(i=0;i<n;i++);
}
//Led Glow function = glows the nth Leds where n is integer but o/p is hex.
void ledglow(int n)
{ n=(n<<20);
PINSEL7 = 0x00000000;
FIO3DIR = 0x0ff00000;
FIO3CLR = 0x0ff00000;
Delay(2000000);
FIO3SET = n;
Delay(2000000);
}

//FLASH Initialisation
void FLASHInit( void )
{

EMC_CTRL |= 0x00000001; /*Disable Address mirror*/
EMC_STA_CFG1 |= 0x00080081;
PCONP |= 0x00000800; /* Turn On EMC PCLK */
PINSEL4 |= 0x00000000; //port 2 set as GPIO
PINSEL5 |= 0x00000001; //port pin 0,1 set to CAS mode
PINSEL6 |= 0x55555555; //function 01 = Data lines of port 3 - P3[0] to P3[15]
//PINSEL8 |= 0x55555555; //function 01 = Address lines of port 4 - P4[1] to P4[15]
PINSEL8 |= 0x55555554; //function 01 = Address lines of port 4 - P4[1] to P4[15]
PINSEL9 |= 0x40051555; //set P4[16] to P4[22] as address lines , P[24] = ~OE, P[25] = ~WE

}

/************************************************************************/
/* PROCEDURE: Check_SST_39VF160X */
/* */
/* This procedure decides whether a physical hardware device has a */
/* SST39VF160X 16 Mbit MPF+ Device installed or not. */
/* */
/* Input: */
/* None */
/* */
/* Output: */
/* return TRUE: indicates a SST39VF160X */
/* return FALSE: indicates not a SST39VF160X */
/************************************************************************/
int Check_SST_39VF160X(void)
{
WORD SST_id1;
WORD SST_id2;
int ReturnStatus;

// Issue the Software Product ID code to 39VF160X
*sysAddress((0x5555)*2) = 0x00AA; // write data 0x00AA to device addr 0x5555
*sysAddress((0x2AAA)*2) = 0x0055; // write data 0x0055 to device addr 0x2AAA
*sysAddress((0x5555)*2) = 0x0090; // write data 0x0090 to device addr 0x5555
Delay(10); // Tida Max 150ns for 39VF160X

// Read the product ID from 39VF160X
SST_id1 = *sysAddress((0x0000)*2); // get first ID byte
SST_id2 = *sysAddress((0x0001)*2); // get second ID byte

// ------------------------------------------------------------
// Determine whether there is a SST 39VF1601 installed or not
// use the following code:

if ((SST_id1 == SST_ID) && (SST_id2 == SST_39VF1601))
ReturnStatus = TRUE;
else
ReturnStatus = FALSE;
// ------------------------------------------------------------
// Or determine whether there is a SST 39VF1602 installed or not
// use the following code:

if ((SST_id1 == SST_ID) && (SST_id2 == SST_39VF1602))
ReturnStatus = TRUE;
else
ReturnStatus = FALSE;
// ------------------------------------------------------------

// Issue the Software Product ID Exit code, thus returning the
// 39VF160X to the normal operation.
*sysAddress((0x5555)*2) = 0x00AA; // write data 0x00AA to device addr 0x5555
*sysAddress((0x2AAA)*2) = 0x0055; // write data 0x0055 to device addr 0x2AAA
*sysAddress((0x5555)*2) = 0x00F0; // write data 0x00F0 to device addr 0x5555
Delay(10); // Tida Max 150ns for 39VF160X
ledglow(1);
return (ReturnStatus);
}


/************************************************************************/
/* PROCEDURE: CFI_Query */
/* */
/* This procedure should be used to query for CFI information */
/* */
/* Input: */
/* Src Source address to store CFI_Query data string */
/* */
/* Output: */
/* None */
/************************************************************************/
void CFI_Query(WORD *Src)
{
WORD index;

// Issue the CFI Query entry code to 39VF160X
*sysAddress((0x5555)*2) = 0x00AA; // write data 0x00AA to device addr 0x5555
*sysAddress((0x2AAA)*2) = 0x0055; // write data 0x0055 to device addr 0x2AAA
*sysAddress((0x5555)*2) = 0x0098; // write data 0x0098 to device addr 0x5555
Delay(10); // insert delay time = Tida

// ----------------------------------------------------------
// Perform all CFI operations here:
// CFI_Query_address is from 0010H--0034H

for (index = 0x0010; index <= 0x0034; index++)
{
*Src = *sysAddress((index)*2);
++Src;
// CFI query data is stored in user-defined memory space.
}
// ----------------------------------------------------------

// Issue the CFI Exit code thus returning the 39VF160X
// to the read operating mode

*sysAddress((0x5555)*2) = 0x00AA; // write data 0x00AA to device addr 0x5555
*sysAddress((0x2AAA)*2) = 0x0055; // write data 0x0055 to device addr 0x2AAA
*sysAddress((0x5555)*2) = 0x00F0; // write data 0x00F0 to device addr 0x5555
Delay(10); // insert delay time = Tida
}


/************************************************************************/
/* PROCEDURE: SecID_Query */
/* */
/* This procedure should be used to query for Security ID information. */
/* */
/* Input: */
/* SST_SecID Source address to store SST SecID string */
/* User_SecID Source address to store User SecID string */
/* */
/* Output: */
/* None */
/************************************************************************/
void SecID_Query(WORD *SST_SecID, WORD *User_SecID)
{

WORD index;
// Issue the SecID Entry code to 39VF160X
*sysAddress((0x5555)*2) = 0x00AA; // write data 0x00AA to device addr 0x5555
*sysAddress((0x2AAA)*2) = 0x0055; // write data 0x0055 to device addr 0x2AAA
*sysAddress((0x5555)*2) = 0x0088; // write data 0x0088 to device addr 0x5555
Delay(10); // insert delay time = Tida

// Perform all Security ID operations here:
// SST programmed segment is from address 000000H--000007H,
// User programmed segment is from address 000010H--000017H.

for (index = 0x0000; index <= 0x0007; index++)
{
*SST_SecID = *sysAddress(index*2);
++SST_SecID;
*User_SecID = *sysAddress((index*2)+0x0010);
++User_SecID;
// Security query data is stored in user-defined memory space.
}
// Issue the Sec ID Exit code thus returning the 39VF160X
// to the read operating mode
*sysAddress((0x5555)*2) = 0x00AA; // write data 0x00AA to device addr 0x5555
*sysAddress((0x2AAA)*2) = 0x0055; // write data 0x0055 to device addr 0x2AAA
*sysAddress((0x5555)*2) = 0x00F0; // write data 0x00F0 to device addr 0x5555
Delay(10); // 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: */
/* return TRUE: indicates success in sector-erase */
/* return FALSE: indicates failure in sector-erase */
/************************************************************************/
int Erase_One_Sector(Uint32 Dst)
{
Uint32 DestBuf = Dst;
int ReturnStatus;

// Issue the Sector Erase command to 39VF160X
*sysAddress((0x5555)*2) = 0x00AA; // write data 0x00AA to device addr 0x5555
*sysAddress((0x2AAA)*2) = 0x0055; // write data 0x0055 to device addr 0x2AAA
*sysAddress((0x5555)*2) = 0x0080; // write data 0x0080 to device addr 0x5555
*sysAddress((0x5555)*2) = 0x00AA; // write data 0x00AA to device addr 0x5555
*sysAddress((0x2AAA)*2) = 0x0055; // write data 0x0055 to device addr 0x2AAA
*sysAddress(DestBuf) = 0x0030; // write data 0x0030 to device sector addr

ReturnStatus = Check_Toggle_Ready(DestBuf); // wait for TOGGLE bit ready

ledglow(2);
return ReturnStatus;
}


/************************************************************************/
/* 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: */
/* return TRUE: indicates success in block-erase */
/* return FALSE: indicates failure in block-erase */
/************************************************************************/
int Erase_One_Block (Uint32 Dst)
{
Uint32 DestBuf = Dst;
int ReturnStatus;

// Issue the Block Erase command to 39VF160X
*sysAddress((0x5555)*2) = 0x00AA; // write data 0x00AA to device addr 0x5555
*sysAddress((0x2AAA)*2) = 0x0055; // write data 0x0055 to device addr 0x2AAA
*sysAddress((0x5555)*2) = 0x0080; // write data 0x0080 to device addr 0x5555
*sysAddress((0x5555)*2) = 0x00AA; // write data 0x00AA to device addr 0x5555
*sysAddress((0x2AAA)*2) = 0x0055; // write data 0x0055 to device addr 0x2AAA
*sysAddress(DestBuf) = 0x0050; // write data 0x0050 to device sector addr

ReturnStatus = Check_Toggle_Ready(DestBuf); // wait for TOGGLE bit ready
ledglow(3);
return ReturnStatus;
}


/************************************************************************/
/* PROCEDURE: Erase_Entire_Chip */
/* */
/* This procedure can be used to erase the entire chip. */
/* */
/* Input: */
/* NONE */
/* */
/* Output: */
/* NONE */
/************************************************************************/
void Erase_Entire_Chip(void)
{
// Issue the Chip Erase command to 39VF160X
*sysAddress((0x5555)*2) = 0x00AA; // write data 0x00AA to device addr 0x5555
*sysAddress((0x2AAA)*2) = 0x0055; // write data 0x0055 to device addr 0x2AAA
*sysAddress((0x5555)*2) = 0x0080; // write data 0x0080 to device addr 0x5555
*sysAddress((0x5555)*2) = 0x00AA; // write data 0x00AA to device addr 0x5555
*sysAddress((0x2AAA)*2) = 0x0055; // write data 0x0055 to device addr 0x2AAA
*sysAddress((0x5555)*2) = 0x0010; // write data 0x0010 to device addr 0x5555

Delay(250000); // Delay Tsce time
ledglow(4);
}


/************************************************************************/
/* PROCEDURE: Program_One_Word */
/* */
/* This procedure can be used to program ONE word of data to the */
/* 39VF160X. */
/* */
/* NOTE: It is necessary to first erase the sector containing the */
/* word to be programmed. */
/* */
/* Input: */
/* SrcWord The WORD which will be written to the 39VF160X */
/* Dst DESTINATION address which will be written with the */
/* data passed in from Src */
/* */
/* Output: */
/* return TRUE: indicates success in word-program */
/* return FALSE: indicates failure in word-program */
/************************************************************************/
int Program_One_Word (WORD *SrcWord, Uint32 Dst)
{
Uint32 DestBuf = Dst;
WORD *SourceBuf = SrcWord;
int ReturnStatus;

printf("\n SourceBuf:%x \nDestBuf:%x ",SourceBuf,DestBuf);
printf("\n *sysAddress(DestBuf) : %x", *sysAddress(DestBuf - system_base));
*sysAddress(((0x5555)*2)) = 0xAA00; // write data 0x00AA to device addr 0x5555
printf("\n 1.0x00AA to 0x5555 %x DONE!",*sysAddress((0x5555)*2));
*sysAddress((0x2AAA)*2) = 0x5500; // write data 0x0055 to device addr 0x2AAA
printf("\n 2.0x0055 to 0x2AAA %x DONE!", *sysAddress((0x2AAA)*2));
*sysAddress((0x5555)*2)= 0xA000; // write data 0x00A0 to device addr 0x5555
printf("\n 3.0x00A0 to 0x5555 %x DONE!", *sysAddress((0x5555)*2));
*sysAddress(DestBuf - system_base) = *(SourceBuf); // transfer the WORD to destination
printf("\n *sysAddress(DestBuf) : %x", *sysAddress(DestBuf - system_base));
printf("\nEntering Toggle Check for Prog_1_word");
ReturnStatus = Check_Toggle_Ready(DestBuf); // wait for TOGGLE bit ready
printf("\n Returnted fron Toggle check in Prog_1_Word");
ledglow(5);
return ReturnStatus;
}


/************************************************************************/
/* PROCEDURE: Program_One_Sector */
/* */
/* This procedure can be used to program a total of 2048 words of data */
/* to the SST39VF160X. */
/* */
/* NOTES: 1. It is necessary to first erase the sector before the */
/* programming. */
/* 2. This sample code assumes the destination address passed */
/* from the calling function is the starting address of the */
/* sector. */
/* */
/* Input: */
/* Src SOURCE address containing the data which will be */
/* written to the 39VF160X */
/* Dst DESTINATION address which will be written with the */
/* data passed in from Src */
/* */
/* Output: */
/* return TRUE: indicates success in sector-program */
/* return FALSE: indicates failure in sector-program */
/************************************************************************/
int Program_One_Sector (WORD *Src, Uint32 Dst)
{

WORD *SourceBuf;
Uint32 DestBuf;
int Index, ReturnStatus;

SourceBuf = Src;
DestBuf = Dst;
printf("\n %x \n%x ",SourceBuf,DestBuf);
ReturnStatus = Erase_One_Sector(DestBuf); // erase the sector first
if (!ReturnStatus)
return ReturnStatus;

for (Index = 0; Index < SECTOR_SIZE; Index++)
{ // transfer data from source to destination
ReturnStatus = Program_One_Word( SourceBuf, DestBuf);
++DestBuf;
++SourceBuf;

if (!ReturnStatus)
return ReturnStatus;
else
ledglow(6);
}

return ReturnStatus;
}


/************************************************************************/
/* PROCEDURE: Program_One_Block */
/* */
/* This procedure can be used to program a total of 32k words of data */
/* to the SST39VF160X. */
/* */
/* NOTES: 1. It is necessary to first erase the block before the */
/* programming. */
/* 2. This sample code assumes the destination address passed */
/* from the calling function is the starting address of the */
/* block. */
/* */
/* Input: */
/* Src SOURCE address containing the data which will be */
/* written to the 39VF160X */
/* Dst DESTINATION address which will be written with the */
/* data passed in from Src */
/* */
/* Output: */
/* return TRUE: indicates success in block-program */
/* return FALSE: indicates failure in block-program */
/************************************************************************/
int Program_One_Block (WORD *Src, Uint32 Dst)
{
WORD *SourceBuf;
Uint32 DestBuf;
int Index, ReturnStatus;

SourceBuf = Src;
DestBuf = Dst;
ReturnStatus = Erase_One_Block(DestBuf); // erase the block first
if (!ReturnStatus)
return ReturnStatus;

for (Index = 0; Index < BLOCK_SIZE; Index++)
{ // transfer data from source to destination
ReturnStatus = Program_One_Word( SourceBuf, DestBuf);
++DestBuf;
++SourceBuf;

if (!ReturnStatus)
return ReturnStatus;
else
ledglow(7);
}

return ReturnStatus;
}


/************************************************************************/
/* PROCEDURE: SecID_Lock_Status */
/* */
/* This procedure should be used to check the Lock Status of SecID */
/* */
/* Input: */
/* None */
/* */
/* Output: */
/* return TRUE: indicates SecID is Locked */
/* return FALSE: indicates SecID is Unlocked */
/************************************************************************/
int SecID_Lock_Status(void)
{
WORD SecID_Status;

// Issue the Sec ID Entry code to 39VF160X
*sysAddress((0x5555)*2) = 0x00AA; // write data 0x00AA to device addr 0x5555
*sysAddress((0x2AAA)*2) = 0x0055; // write data 0x0055 to device addr 0x2AAA
*sysAddress((0x5555)*2) = 0x0088; // write data 0x0088 to device addr 0x5555
Delay(10); // insert delay time = Tida

// Read Lock Status of SecID segment
SecID_Status = *sysAddress((0x00FF)*2);
SecID_Status &= 0x0008; // Unlocked: DQ3=1; Locked: DQ3=0

// Issue the Sec ID Exit code thus returning the 39VF160X
// to the read operating mode
*sysAddress((0x5555)*2) = 0x00AA; // write data 0x00AA to device addr 0x5555
*sysAddress((0x2AAA)*2) = 0x0055; // write data 0x0055 to device addr 0x2AAA
*sysAddress((0x5555)*2) = 0x00F0; // write data 0x00F0 to device addr 0x5555
Delay(10); // insert delay time = Tida

if (!SecID_Status)
return TRUE; // SecID segment is Locked

return FALSE; // SecID segment is Unlocked
}


/************************************************************************/
/* PROCEDURE: User_SecID_Word_Program */
/* */
/* This procedure can be used to program data into the User SecID */
/* segment (from 000010H--000017H) in 39VF160X. */
/* */
/* NOTE: 1. It's recommended to lock out the SecID segment after the */
/* completion of program. */
/* 2. There's no way to unlock the SecID segment once it's */
/* locked. */
/* */
/* Input: */
/* SrcWord Source address to fetch data */
/* Dst Destination address to write data */
/* length number of word needs to be programmed */
/* */
/* Output: */
/* return TRUE: indicates SecID program is successful */
/* return FALSE: indicates SecID program is failed or SecID */
/* is locked. */
/************************************************************************/
int User_SecID_Word_Program (WORD *SrcWord, WORD *Dst, int length)
{
WORD *DestBuf = Dst;
WORD *SourceBuf = SrcWord;
int test, index=length;

test = SecID_Lock_Status (); // check whether the SecID is Locked or not
if (test) // TRUE: SecID is Locked
return FALSE;

while (index--)
{
*sysAddress((0x5555)*2) = 0x00AA; // write data 0x00AA to device addr 0x5555
*sysAddress((0x2AAA)*2) = 0x0055; // write data 0x0055 to device addr 0x2AAA
*sysAddress((0x5555)*2) = 0x00A5; // write data 0x00A5 to device addr 0x5555
*sysAddress(DestBuf) = *SourceBuf; // transfer the WORD to destination
++DestBuf;
++SourceBuf;
// Read the toggle bit to detect end-of-write for the Sec ID.
// Do Not use Data# Polling for User_SecID_Word_Program.
test = Check_Toggle_Ready((Uint32)DestBuf); // wait for TOGGLE bit to get ready
if (!test)
return FALSE; // SecID Word-Program failed!
}

return TRUE;
}


/************************************************************************/
/* PROCEDURE: User_SecID_Lock_Out */
/* */
/* This procedure can be used to Lock Out the User Seccurity ID. */
/* User Security ID segment, from 000010H--000017H, in 39VF160X. */
/* */
/* NOTE: 1. Call SecID_Lock_Status() first to verify the SecID is */
/* unlocked. */
/* 2. SecID segment can't be erased. */
/* 3. SecID segment can't be unlocked once it's locked. */
/* */
/* Input: None */
/* */
/* Output: None */
/************************************************************************/
void User_SecID_Lock_Out (void)
{
*sysAddress((0x5555)*2) = 0x00AA; // write data 0x00AA to device addr 0x5555
*sysAddress((0x2AAA)*2) = 0x0055; // write data 0x0055 to device addr 0x2AAA
*sysAddress((0x5555)*2) = 0x0085; // write data 0x0085 to device addr 0x5555
*sysAddress((0x00FF)*2) = 0x0000; // write data 0x0000 to any addr

Delay(500); // Wait for Word-Program timeout, Tbp=10us
}


/************************************************************************/
/* PROCEDURE: Erase_Suspend */
/* */
/* This procedure can be used to temporarily suspend a Sector/Block- */
/* Erase operation in 39VF160X. */
/* */
/* Input: None */
/* */
/* Output: None */
/************************************************************************/
void Erase_Suspend (void)
{
*sysAddress((0x5555)*2) = 0x00B0; // write data 0x00B0 to any addr, i.e. 0x5555

Delay(1000); // The device automatically enters read mode
// typically within 20 us after the Erase-Suspend command issued.
}


/************************************************************************/
/* PROCEDURE: Erase_Resume */
/* */
/* This procedure can be used to resume a Sector-Erase or Block-Erase */
/* operation that had been suspended in 39VF160X. */
/* */
/* Input: None */
/* */
/* Output: None */
/************************************************************************/
void Erase_Resume (void)
{
*sysAddress((0x5555)*2) = 0x0030; // write data 0x0030 to any addr, i.e. 0x5555
}


/************************************************************************/
/* PROCEDURE: Check_Toggle_Ready */
/* */
/* During the internal program cycle, any consecutive read operation */
/* on DQ6 will produce alternating 0's and 1's i.e. toggling between */
/* 0 and 1. When the program cycle is completed, DQ6 of the data will */
/* stop toggling. After the DQ6 data bit stops toggling, the device is */
/* ready for next operation. */
/* */
/* Input: */
/* Dst must already be set-up by the caller */
/* */
/* Output: TRUE Data toggling success */
/* FALSE Time out */
/************************************************************************/
int Check_Toggle_Ready (Uint32 Dst)
{
WORD PreData;
WORD CurrData;
unsigned long TimeOut = 0;

PreData = *sysAddress(Dst);
PreData = PreData & 0x0040; // read DQ6
printf("\n PreData:%x",PreData);
while (TimeOut < MAX_TIMEOUT) // MAX_TIMEOUT=0x07FFFFFF
{
CurrData = *sysAddress(Dst);
CurrData = CurrData & 0x0040; // read DQ6 again
printf("\n In WHILE for toggle DQ6");
if (PreData == CurrData)
{
ledglow(8);
return TRUE;
}
PreData = CurrData;
TimeOut++;
}
printf("\n Out of WHILE for DQ6");
ledglow(14);
return FALSE;
}


/************************************************************************/
/* PROCEDURE: Check_Data_Polling */
/* */
/* During the internal program cycle, any attempt to read DQ7 of the */
/* last byte loaded during the page/byte-load cycle will receive the */
/* complement of the true data. Once the program cycle is completed, */
/* DQ7 will show true data. */
/* */
/* Input: */
/* Dst must already be set-up by the caller */
/* TrueData this is the original (true) data */
/* */
/* Output: */
/* TRUE Data polling success */
/* FALSE Time out */
/************************************************************************/
int Check_Data_Polling (Uint32 Dst, WORD TrueData)
{
WORD CurrData;
unsigned long int TimeOut = 0;

TrueData = TrueData & 0x0080; // read D7
while (TimeOut < MAX_TIMEOUT) // MAX_TIMEOUT=0x07FFFFFF
{
CurrData = *sysAddress(Dst);
CurrData = CurrData & 0x0080; // read DQ7
if (TrueData == CurrData)
{
ledglow(9);
return TRUE;
}
TimeOut++;
}
return FALSE;
}

void Read(WORD *loc, WORD Numbyte )
{
unsigned int i;
// unsigned int temp2,temp1;
WORD * pt;
WORD Num;
pt=loc;
Num = Numbyte;
for(i=0;i<Num;i++)
{
// temp1=(*pt);
//temp2=temp1;
//temp2=(temp2<<20);
//while((unsigned int)pt3 < (FLASH_BASE + FLASH_SIZE))
// { printf("%x ",*pt3++ ;}

// printf("\n %x \n%x ",temp2, pt);
// printf("\n %x ",temp2);
printf("\n %x %x",pt,*pt);
pt++;
ledglow(15);

}
// ledglow(3);

}

int main()
{
WORD *ptr;
Uint32 Address;
WORD *AddSDRAM;


ptr = (unsigned int *) system_base;
Address = system_base;
AddSDRAM = (unsigned int *)SDRAM_BASE;
//Initialisations
init_serial(9600);
SDRAMInit();
FLASHInit();
//Write the SDRAM to access data from there for write
ClearMemory();
FillMemory(1);

ledglow(10);

Check_SST_39VF160X();
//CFI_Query(WORD*);
//SecID_Query(WORD*, WORD*);
//Erase_One_Sector(Address);
//Erase_One_Block (Address);
//Erase_Entire_Chip();
//Read(ptr, 50);
printf("\n AddSDRAM:%x \nAddress:%x ",AddSDRAM, Address);
Program_One_Word (AddSDRAM, Address);
Read(ptr,50);
//Program_One_Sector (SDRAM_BASE, Address);
//Program_One_Block (WORD *Src, Uint32 Dst);
//SecID_Lock_Status(void);
//User_SecID_Word_Program (WORD*, WORD*, int);
//User_SecID_Lock_Out (void);
//Erase_Suspend (void);
//Erase_Resume (void);
//Check_Toggle_Ready (Uint32);
//Check_Data_Polling (Uint32, WORD);

ledglow(51);
}
-----------------------------------------------------------------------------------------------


Please let me know.. what is going wrong...


-SAKU
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top