AnsweredAssumed Answered

How can i store some data into flexNVM or flash memory ?

Question asked by Jo sol on Oct 30, 2015
Latest reply on Nov 2, 2015 by Jo sol

Hi.

 

settitng :

I am using MK64FN1M0VLL12 MCU  , KDS 3.0.0,  MQX V 1.1.1

 

 

Question :

I want to store some data into NVM or flash before Power down.

and right after Power on again , I want to read the data.and i added component successfully

 

and i found a useful post -> Re: Erasing Flash sectors in KL25 on the Freedom Board.

 

and i successfully write and read a data at first time. but it didn't work at second time

 

while debugging, i found that in UnhandledInterrupt, the process stoped.

 

can i get a answer about this problem? it's my code, and debugging window. i post the problem in MQX community because it may be problem in MQX interrupt 

 

thank you very much

 

(someone told me that this was happening because the sector that i was trying to write to was not erased. the PE generated code does not erase the sector for me prior to writing to it, and i have to erase it myself but i don't know how can i erase the sector , should i edit MQX??)

 

------------------------------------------------------------------------------------------------------------------------------------------------------

uint8 FromPtr[6] = {0x1F, 0x2F, 0x3F, 0x4F, 0x5F, 0x6F};

uint8 ToPtr[6];

int OpStatus;

LDD_TError OpStatus;

LDD_TDeviceData* FLASH1Pointer;

 

 

FLASH1Pointer = FLASH1_Init(NULL);

 

FLASH1_Erase(FLASH1Pointer, 0xFFFFA, 0x6);  //erase

  do {

  FLASH1_Main(FLASH1Pointer);

  OpStatus = FLASH1_GetOperationStatus(FLASH1Pointer);

  } while (!((OpStatus == LDD_FLASH_IDLE) | (OpStatus == LDD_FLASH_FAILED)));

 

  FLASH1_Write(FLASH1Pointer, FromPtr, 0xFFFFA, 0x6);  //write

  do {

  FLASH1_Main(FLASH1Pointer);

  OpStatus = FLASH1_GetOperationStatus(FLASH1Pointer);

  } while (!((OpStatus == LDD_FLASH_IDLE) | (OpStatus == LDD_FLASH_FAILED)));

  FLASH1_Read(FLASH1Pointer,0xFFFFA, ToPtr, 0x6);  //read

  do {

  FLASH1_Main(FLASH1Pointer);

  OpStatus = FLASH1_GetOperationStatus(FLASH1Pointer);

  } while (!((OpStatus == LDD_FLASH_IDLE) | (OpStatus == LDD_FLASH_FAILED)));

 

------------------------------------------------------------------------------------------------------------------------------------------------------

Attachments

Outcomes