why erase FLASH failed?

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

why erase FLASH failed?

Jump to solution
3,799 Views
terrybogard
Contributor II

#define MY_FLASH_LOCATION 0x00007C00 /* Flash memory location the data will be written to */

volatile bool DataWrittenFlg = FALSE;
LDD_TError Error;
LDD_FLASH_TOperationStatus OpStatus;
LDD_TDeviceData *MyFLASH_Ptr;
//UInt16 DataTest[] = {0,1,2,3,4,5,6,7,8,9};
//UInt16 *pClbrtData = 0;


void SaveClbrtData(void)
{
static UInt16 Cnt = 0;

MyFLASH_Ptr = FLASH1_Init(NULL); /* Initialization of FLASH1 component */
Error = FLASH1_Erase(MyFLASH_Ptr, MY_FLASH_LOCATION, 1024); /* Start erase to the flash memory */
/* Here some other application code can be placed */
while (!DataWrittenFlg)
{ /* Wait until the data are written */
FLASH1_Main(MyFLASH_Ptr); /* Run the main method */
Cnt++;
if(Cnt > 300)
{
break;
}
}

Device: MC56F82748

dear NXP expert, 

i try to erase a sector .p_FlashData (RWX) : ORIGIN = 0x00007C00, LENGTH = 0x00000400,

i am sure the FTFA_PDD_SetFCCOBCommand and FTFA_PDD_SetFCCOBAddress set as expected, no memory protected, FTFA_FPROTn bits are all 1.But i the memory corresponding no change to 0xFFFF, is there any operation need further?

thanks.

 

0 Kudos
1 Solution
3,782 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Alexander,

I suggest you use another flash bean rather than the one you use.

I attach an simple example to write flash based on MC56F82748 and PE, hope it can help you.

BR

XiangJun Rong

View solution in original post

0 Kudos
8 Replies
3,228 Views
cabl
Contributor III

Hi evreybody,

I´m using a 56F82646 part and having some trouble with this component. To my understanding there´s something odd in the PE code for the SafeRoutineCaller:

- when stack location where SaveRoutineStackSpace is placed is under 0x7FF (RAM address), SafeRoutineInDataPtr gets a value under 0xFFF (double of SaveRoutineStackSpace address), and SafeRoutineInCodePtr=0xF000 + SafeRoutineInDataPtr is a valid address under 0xFFFF and everything works fine. At least this es what I can see in the debugger.

- when stack location where SaveRoutineStackSpace is placed is over 0x7FF, SafeRoutineInDataPtr gets a value over 0xFFF and SafeRoutineInCodePtr=0xF000 + SafeRoutineInDataPtr is a INVALID address (over 0xFFFF). Now it does not work.

If I force SaveRoutineStackSpace to be global and be placed at low RAM addresses it always work fine, without any other change in the code, just the SaveRoutineStackSpace position.

This behaviour seems to be independent of the memory model and width of the pointer used in the project options.

Am I not understanding something here? 

Thanks in advance.

Tags (1)
0 Kudos
3,168 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

Pls try to use large data mode and have a try.

BR

XiangJun Rong

0 Kudos
3,225 Views
cabl
Contributor III
 
0 Kudos
3,800 Views
terrybogard
Contributor II

if (DeviceDataPrv->CurrentOperation != LDD_FLASH_READ) {
FTFA_PDD_SetFCCOBCommand(FTFA_BASE_PTR, DeviceDataPrv->CurrentCommand); /* Set the desired flash operation command */
FTFA_PDD_SetFCCOBAddress(FTFA_BASE_PTR, ((uint32_t)(DeviceDataPrv->CurrentFlashAddress - DstAddrOffset))); /* Set an address of the flash memory location for the current flash operation command */
/* {Default RTOS Adapter} Critical section begin, general PE function is used */
EnterCritical();
DeviceDataPrv->SafeRoutineInCodePtr(); /* Run the Safe routine */
/* {Default RTOS Adapter} Critical section end, general PE function is used */
ExitCritical();
}

0 Kudos
3,783 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Alexander,

I suggest you use another flash bean rather than the one you use.

I attach an simple example to write flash based on MC56F82748 and PE, hope it can help you.

BR

XiangJun Rong

0 Kudos
3,773 Views
terrybogard
Contributor II

and how can i write the struct type to the destination?

0 Kudos
3,762 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

As you know that a struct includes multiple data type, for example byte, word, long word..., but the flash writing requires standard 16 bits data type(word type), so I think you can define a word array, copy the struct variable to the standard array.

Hope it can help you

BR

XiangJun Rong

0 Kudos
3,779 Views
terrybogard
Contributor II

hi xiangjun,

why you suggest use another flash bean.

I test your code, that's work well.

thanks a lot.

0 Kudos