K60N512 Memory

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

K60N512 Memory

1,314 Views
vines
Contributor III

Hi,

I read on the datasheet that this particular MCU that I am using does not have an NVM part. I plan to use the upper portion of flash as data storage. Without NVM, is it still possible to configure this portion as data storage? I tried doing it nevertheless. The first time I write it is successful. However the second time, the debugger hangs. I traced the problem that it returns at function FLASH1_Main().

Specifically at line:

if(((DataToPrg & DataToPrgMask) & (~CurrentFlashPrgUnitData)) > 0U) {

          DeviceDataPrv->CurrentErrorFlags |= LDD_FLASH_MULTIPLE_WRITE_ERROR;

          return;

        }

As you can see the error is multiple error. Is there any workaround to this problem given that I will not change the MCU with NVM? If yes, How should I do it?

By the way linker file I tried configuring the portion where I want to write as RWX but to no avail.

I am using Codewarrior 10.2 and MQX 3.8.

Thank You.


Labels (1)
0 Kudos
Reply
4 Replies

937 Views
danieldelatorre
Contributor IV

I had exactly the same problem, this was happening because the sector that you were trying to write to was not erased.  The PE generated code does not erase the sector for you prior to writing to it, you have to erase it yourself.  I hope this helps someone else.

0 Kudos
Reply

937 Views
josol
Contributor III

please explain in detail~

The first time I write it is successful too, However the second time, debugger stop at the UnhandledInterrupt in Ventors,c

can i get a advice ??

0 Kudos
Reply

937 Views
josol
Contributor III

Thanks to Jorge Gonzalez's help

I solve the problem.

Thank you.

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

0 Kudos
Reply

937 Views
vines
Contributor III

By the way I copied the settings on this link Erasing Flash sectors in KL25 on the Freedom Board.

I allocated space for flash component as well.

I'll paste my functions below.

bool readInternalFlash(u32 address, u8 * data, u16 len)

{

    FLASH1_Read(flash_Ptr, address, data, len);    // Start reading from the flash memory

    do {

        FLASH1_Main(flash_Ptr);

        OpStatus = FLASH1_GetOperationStatus(flash_Ptr);

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

    if (OpStatus == LDD_FLASH_FAILED)

        return false;

   

    return true;

}

bool writeInternalFlash(u32 address, u8 * data, u16 len)

{

    FLASH1_Write(flash_Ptr, data, address, len);  

    while (!DataWrittenFlg) {                                                

        FLASH1_Main(flash_Ptr);                                               

    }

    DataWrittenFlg = FALSE;

    if (FLASH1_GetOperationStatus(flash_Ptr) == LDD_FLASH_FAILED)

        return false;

    readInternalFlash(address, data, len);

    return true;

}

bool eraseInternalFlash(u32 address, u16 len)

{

    if (FLASH1_Erase(flash_Ptr, address, len) == ERR_OK)  

        return true;

    else

        return false;

}


0 Kudos
Reply