Hi Kan,
First, thanks for your support. I tried the process you suggested but it did not work.
And since final application will be developed on the MKL05Z32VLF4 microcontroller, which doesn't have any flex_memory.
So the only option left to preserve data and use after power reset is to store required data into the programming Flash. I have one FLASH_LDD method in CW. I am using that function to read and write the data.
I have done all settings and created "use user memory area" . My test code according to one example code in community is as below:
#define location 0x200
char Data[20] = "Hello";
char Buffer[11] = " ";
LDD_TError Error;
volatile bool DataWrittenFlg = FALSE;
LDD_FLASH_TOperationStatus OpStatus;
/* Write your code here */
for(;;) {
Error = FLASH1_Write(flash, Data, location, sizeof(Data));
while (!DataWrittenFlg) { /* Wait until the data are written */
}
DataWrittenFlg = FALSE;
if (FLASH1_GetOperationStatus(flash) == LDD_FLASH_FAILED) { /* Check if the operation has successfully ended */
/* Error state solution */
}
Error = FLASH1_Read(flash, location, Buffer, sizeof(Data));
do {
FLASH1_Main(flash);
OpStatus = FLASH1_GetOperationStatus(flash);
} while (!((OpStatus == LDD_FLASH_IDLE) | (OpStatus == LDD_FLASH_FAILED)));
if (OpStatus == LDD_FLASH_FAILED) { /* Check if the operation has successfully ended */
/* Error state solution */
}
printf(" Received Data %s \n", Buffer);
WAIT1_Waitms(1000);
}
/*** Don't write any code pass this line
Even it is not working accordingly. Please help me in preserving the required data in Flash memory either by refining the above code or by providing any alternative option.
Thanks,
Joginder Rana