Hi!
I have a strange problem with SPIFI flash block erase on LPC4330. I am using lpcspifilib. Generally the spifiEraseAll function is working properly but I need to perform block erase. Below is my code:
SPIFI_ERR_T result;
SPIFI_HANDLE_T * spifiHandle = spifiInitDevice(&spifiHandleBuffer,sizeof(spifiHandleBuffer),SPIFI_CONTROLLER_ADDRESS, (uint32_t) manParams->address);
spifiDevSetOpts(spifiHandle, SPIFI_OPT_USE_QUAD, false);
spifiDevSetMemMode(spifiHandle, false);
uint32_t maxSpifiClock = spifiDevGetInfo(spifiHandle, SPIFI_INFO_MAXCLOCK);
Chip_Clock_SetDivider(CLK_IDIV_E,CLKIN_MAINPLL,(1+(Chip_Clock_GetClockInputHz(CLKIN_MAINPLL)/maxSpifiClock)));
result = spifiDevUnlockDevice(spifiHandle);
// if there are any errors - operation failed
if (result != SPIFI_ERR_NONE)
{
result = spifiDevLockDevice(spifiHandle);
result = spifiDevDeInit(spifiHandle);
return USBD_STATUS_FAILED;
}
uint32_t * header = (uint32_t *) params->recData;
result = spifiEraseByAddr(spifiHandle, (uint32_t) LPC4330_APPLICATION_BASE_ADDRESS, (uint32_t) (LPC4330_APPLICATION_BASE_ADDRESS + 72));
if (result != SPIFI_ERR_NONE)
{
result = spifiDevLockDevice(spifiHandle);
result = spifiDevDeInit(spifiHandle);
return USBD_STATUS_FAILED;
}
//result = spifiDevRead(spifiHandle, manParams->address, &checkBuffer, params->wLength);
result = spifiDevLockDevice(spifiHandle);
result = spifiDevDeInit(spifiHandle);
return USBD_STATUS_SUCCESS;
spifiInit function, registering family, pin and clock configuration are done on the start of the application. The next strange thing - this code worked... and in one moment it stopped working. Am I doing everything properly?