SPIFI rewriting problem.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SPIFI rewriting problem.

555 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lintovincent88 on Thu Mar 26 01:54:24 MST 2015
Hi,
    There is small problem in my spifi flash program. i can write and read the data into flash one time, when am write again int that address again i am getting 0.writing into same address results zero.and not the updated value. iam using LPC xpresso and processor is LPC 4088.
flash = S25FL127SABMFI101. am using prebuilt library for spifi. Below is the program part am used for spifi read/write. please tell me if there is anything i have to do in this code.






spifi_io_clk_init();                                   //pin initialisn
LPC_SC->SPIFICLKSEL |= 0x00000102;       //clock selection

errCode = spifiInit(LPC_SPIFI_BASE, true);         //LPC_spifi base is =0x20094000UL
spifiRegisterFamily(spifi_REG_FAMILY_CommonCommandSet);
memSize = spifiGetHandleMemSize(LPC_SPIFI_BASE);
if (memSize == 0)
{
/* No device detected, error */
return (SPIFI_ERR_GEN);
}

pSpifiHandle = spifiInitDevice(&lmem, sizeof(lmem), LPC_SPIFI_BASE,SPIFLASH_BASE_ADDRESS); 
//SPIFLASH_BASE_ADDRESS =0x2800 0000
if (pSpifiHandle == NULL)
{
return (SPIFI_ERR_GEN);
}
/* Get some info needed for the application */
maxSpifiClock = spifiDevGetInfo(pSpifiHandle, SPIFI_INFO_MAXCLOCK);
/* turn on memmode on for default */
spifiDevSetMemMode(pSpifiHandle, true);
spifiDevSetOpts(pSpifiHandle,SPIFI_OPT_USE_QUAD,1);
spifiDevUnlockDevice(pSpifiHandle);
errCode = spifiProgram(pSpifiHandle,SPIFLASH_BASE_ADDRESS1,data_X,sizeof data_X);
errCode = spifiRead(pSpifiHandle,SPIFLASH_BASE_ADDRESS1,data_R,sizeof data_R);




thanks and regards
Linto
Labels (1)
0 Kudos
3 Replies

427 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mc on Fri Mar 27 06:33:46 MST 2015
Hi,
Yes, Flash needs to be erased before programming.

0 Kudos

427 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lintovincent88 on Thu Mar 26 20:55:01 MST 2015
Thank you MC,.. now its working. i have a small doubt?? is it really necessary to erase every time before write??
0 Kudos

427 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mc on Thu Mar 26 08:53:44 MST 2015
Hi Linto,
Do you erase flash before programming? You will need below function calls before erasing/programming like below
spifiDevSetOpts(pSpifi, SPIFI_OPT_USE_QUAD, false);
spifiDevSetMemMode(pSpifi, false);

You can also look into example here.
http://www.lpcware.com/system/files/lpcopen_2_12_lpcxpresso_keil_mcb_1857_SPIFI_23Feb15.zip
0 Kudos